rewrite version func

This commit is contained in:
onyx-and-iris 2026-02-16 01:29:25 +00:00
parent 5057029267
commit 229bc4a15f
2 changed files with 16 additions and 14 deletions

View File

@ -79,14 +79,15 @@ func main() {
}),
kong.Vars{
"version": func() string {
if version == "" {
if version != "" {
return version
}
info, ok := debug.ReadBuildInfo()
if !ok {
return "(unable to read build info)"
return "(unable to read version)"
}
version = strings.Split(info.Main.Version, "-")[0]
}
return version
return strings.Split(info.Main.Version, "-")[0]
}(),
},
)

View File

@ -77,14 +77,15 @@ func main() {
}),
kong.Vars{
"version": func() string {
if version == "" {
if version != "" {
return version
}
info, ok := debug.ReadBuildInfo()
if !ok {
return "(unable to read build info)"
return "(unable to read version)"
}
version = strings.Split(info.Main.Version, "-")[0]
}
return version
return strings.Split(info.Main.Version, "-")[0]
}(),
},
)