mirror of
https://github.com/onyx-and-iris/gogn.git
synced 2026-08-21 12:14:25 +00:00
move versionFromBuild()
This commit is contained in:
24
main.go
24
main.go
@@ -17,6 +17,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: "gogn",
|
Use: "gogn",
|
||||||
@@ -73,15 +85,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]
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user