chore(version): Get the version following how katenary is installed
This commit is contained in:
@@ -1,4 +1,24 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Version is the version of katenary. It is set at compile time.
|
||||
var Version = "master" // changed at compile time
|
||||
|
||||
// GetVersion return the version of katneary. It's important to understand that
|
||||
// the version is set at compile time for the github release. But, it the user get
|
||||
// katneary using `go install`, the version should be different.
|
||||
func GetVersion() string {
|
||||
if strings.HasPrefix(Version, "release-") {
|
||||
return Version
|
||||
}
|
||||
// get the version from the build info
|
||||
v, ok := debug.ReadBuildInfo()
|
||||
if ok {
|
||||
return v.Main.Version + "-" + v.GoVersion
|
||||
}
|
||||
return Version
|
||||
}
|
||||
|
Reference in New Issue
Block a user