diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 1e3031b..10ccba6 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -15,7 +15,7 @@ builds: - amd64 - arm64 ldflags: - - -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} + - -s -w -X main.version={{ .Version }} archives: - format: tar.gz diff --git a/main.go b/main.go index 7af1e26..d2545e3 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,6 @@ import ( "path/filepath" "regexp" "runtime" - "runtime/debug" "strconv" "strings" "sync" @@ -228,6 +227,8 @@ func checkCtagsInstallation() error { return nil } +var version = "unknown" // Populated with -X main.version + // Main Function func main() { config := parseFlags() @@ -244,8 +245,7 @@ func main() { } if config.showVersion { - version, commitHash := getVersionInfo() - fmt.Printf("CTags Language Server version %s (commit %s)\n", version, commitHash) + fmt.Printf("CTags Language Server version %s\n", version) os.Exit(0) } @@ -329,37 +329,6 @@ Options: `, os.Args[0]) } -func getVersionInfo() (version, commitHash string) { - buildInfo, ok := debug.ReadBuildInfo() - if !ok || buildInfo == nil { - return "unknown", "unknown" - } - - version = buildInfo.Main.Version - - var revision, modified string - for _, setting := range buildInfo.Settings { - switch setting.Key { - case "vcs.revision": - revision = setting.Value - case "vcs.modified": - modified = setting.Value - } - } - - if len(revision) >= 7 { - commitHash = revision[:7] - } else { - commitHash = revision - } - - if modified == "true" { - commitHash += "-dirty" - } - - return version, commitHash -} - // handleRequest routes JSON-RPC requests to appropriate handlers func handleRequest(server *Server, req RPCRequest) { switch req.Method {