Skip to content

Commit e35ee50

Browse files
committed
fix: show module version instead of 'dev' for go install builds
go install doesn't set ldflags, so Version stays empty. The fallback checked vcs.revision which go install also doesn't embed. Now checks info.Main.Version first, which go install does set to the module pseudo-version. Also: compress social-preview.png from 1.0M to 401K for GitHub upload. Assisted-By: Claude Opus 4
1 parent 85cf05e commit e35ee50

5 files changed

Lines changed: 16 additions & 0 deletions

File tree

docs/assets/social-preview.png

-640 KB
Loading

knowledgeprim/internal/cli/version.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ func resolveVersion() string {
3030
return Version
3131
}
3232
if info, ok := debug.ReadBuildInfo(); ok {
33+
// go install sets Main.Version to the module version.
34+
if v := info.Main.Version; v != "" && v != "(devel)" {
35+
return v
36+
}
3337
for _, s := range info.Settings {
3438
if s.Key == "vcs.revision" && len(s.Value) >= 7 {
3539
return s.Value[:7]

queueprim/internal/cli/version.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ func resolveVersion() string {
3030
return Version
3131
}
3232
if info, ok := debug.ReadBuildInfo(); ok {
33+
// go install sets Main.Version to the module version.
34+
if v := info.Main.Version; v != "" && v != "(devel)" {
35+
return v
36+
}
3337
for _, s := range info.Settings {
3438
if s.Key == "vcs.revision" && len(s.Value) >= 7 {
3539
return s.Value[:7]

stateprim/internal/cli/version.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ func resolveVersion() string {
3030
return Version
3131
}
3232
if info, ok := debug.ReadBuildInfo(); ok {
33+
// go install sets Main.Version to the module version.
34+
if v := info.Main.Version; v != "" && v != "(devel)" {
35+
return v
36+
}
3337
for _, s := range info.Settings {
3438
if s.Key == "vcs.revision" && len(s.Value) >= 7 {
3539
return s.Value[:7]

taskprim/internal/cli/version.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ func resolveVersion() string {
3030
return Version
3131
}
3232
if info, ok := debug.ReadBuildInfo(); ok {
33+
// go install sets Main.Version to the module version.
34+
if v := info.Main.Version; v != "" && v != "(devel)" {
35+
return v
36+
}
3337
for _, s := range info.Settings {
3438
if s.Key == "vcs.revision" && len(s.Value) >= 7 {
3539
return s.Value[:7]

0 commit comments

Comments
 (0)