You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by ho...@apache.org on 2025/07/07 08:07:34 UTC

(skywalking-eyes) branch fix-version-output-for-go-install created (now f909e81)

This is an automated email from the ASF dual-hosted git repository.

hoshea pushed a change to branch fix-version-output-for-go-install
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git


      at f909e81  Fix version output for go install installations

This branch includes the following new commits:

     new f909e81  Fix version output for go install installations

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(skywalking-eyes) 01/01: Fix version output for go install installations

Posted by ho...@apache.org.
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 <fg...@gmail.com>
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 <no...@anthropic.com>
---
 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
+		}
+	}
+}