move versionFromBuild()

This commit is contained in:
2026-08-19 14:05:24 +01:00
parent 3f8df53daf
commit 7eb22f58c3

24
main.go
View File

@@ -16,6 +16,18 @@ import (
var version string // Version of the CLI, set during build time var version string // Version of the CLI, set during build time
func versionFromBuild() string {
if version != "" {
return version
}
info, ok := debug.ReadBuildInfo()
if !ok {
return "(unable to read version)"
}
return strings.Split(info.Main.Version, "-")[0]
}
// rootCmd represents the base command when called without any subcommands. // rootCmd represents the base command when called without any subcommands.
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "ignr", Use: "ignr",
@@ -79,15 +91,3 @@ func main() {
os.Exit(1) os.Exit(1)
} }
} }
func versionFromBuild() string {
if version != "" {
return version
}
info, ok := debug.ReadBuildInfo()
if !ok {
return "(unable to read version)"
}
return strings.Split(info.Main.Version, "-")[0]
}