mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-03-14 17:05:14 +00:00
*Written by Claude on behalf of @silverwind* When installed via `go run module@version` or `go install module@version`, the Go toolchain embeds the module version in the binary. Use `debug.ReadBuildInfo` to read it as a fallback when `Version` has not been set via ldflags, so that `go run gitea.com/gitea/gitea-mcp@latest` will reports the latest tag version instead of `dev`. Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/155 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-committed-by: silverwind <me@silverwind.io>
24 lines
375 B
Go
24 lines
375 B
Go
package main
|
|
|
|
import (
|
|
"runtime/debug"
|
|
|
|
"gitea.com/gitea/gitea-mcp/cmd"
|
|
"gitea.com/gitea/gitea-mcp/pkg/flag"
|
|
)
|
|
|
|
var Version = "dev"
|
|
|
|
func init() {
|
|
if Version == "dev" {
|
|
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" && info.Main.Version != "(devel)" {
|
|
Version = info.Main.Version
|
|
}
|
|
}
|
|
flag.Version = Version
|
|
}
|
|
|
|
func main() {
|
|
cmd.Execute()
|
|
}
|