This is an automated email from the ASF dual-hosted git repository. hoshea pushed a commit to branch fix-version-output-for-go-install in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git
commit f909e815b238276231509038386501c3372264a5 Author: fgksgf <[email protected]> AuthorDate: Mon Jul 7 16:07:24 2025 +0800 Fix version output for go install installations When users install license-eye via `go install`, the version shows "dev" instead of the correct version number. This happens because go install doesn't use the Makefile's -ldflags to inject version information. This fix adds a fallback mechanism that reads version information from build metadata when ldflags injection is not available, while maintaining full compatibility with existing build processes. Changes: - Add runtime/debug import to read build information - Implement version fallback: ldflags → build info → "dev" - Maintain backward compatibility with existing Makefile builds - Users installing via go install will now see correct version 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> --- commands/version.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/commands/version.go b/commands/version.go index 6d1772f..c84b155 100644 --- a/commands/version.go +++ b/commands/version.go @@ -17,4 +17,17 @@ package commands +import ( + "runtime/debug" +) + var version = "dev" + +func init() { + // Try to get version from build info first (for go install) + if info, ok := debug.ReadBuildInfo(); ok { + if info.Main.Version != "" && info.Main.Version != "(devel)" { + version = info.Main.Version + } + } +}
