Merge pull request #60 from lyyyuna/goc-auto-version
support goc version using `go get`
This commit is contained in:
commit
7d2d49cf5a
@ -18,6 +18,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -33,7 +34,15 @@ var versionCmd = &cobra.Command{
|
|||||||
goc version
|
goc version
|
||||||
`,
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
// if it is "Unstable", means user build local or with go get
|
||||||
|
if version == "Unstable" {
|
||||||
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
fmt.Println(info.Main.Version)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// otherwise the value is injected in CI
|
||||||
fmt.Println(version)
|
fmt.Println(version)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user