chore(dev): changed how to test version
- force release version check to use "v" (or not) as first character - one line condtion
This commit is contained in:
@@ -13,15 +13,13 @@ var Version = "master" // changed at compile time
|
|||||||
// katneary using `go install`, the version should be different.
|
// katneary using `go install`, the version should be different.
|
||||||
func GetVersion() string {
|
func GetVersion() string {
|
||||||
// try to get the semantic version from the Version variable (theorically set at compile time)
|
// try to get the semantic version from the Version variable (theorically set at compile time)
|
||||||
reg := regexp.MustCompile(`^(.?\d+.\d+.\d+.*)|^release-.*`)
|
if reg := regexp.MustCompile(`^v?\d+.\d+.\d+.*|^release-.*`); reg.MatchString(Version) {
|
||||||
if reg.MatchString(Version) {
|
|
||||||
return Version
|
return Version
|
||||||
}
|
}
|
||||||
|
|
||||||
// OK... let's try to get the version from the build info
|
// OK... let's try to get the version from the build info
|
||||||
// get the version from the build info (when installed with go install)
|
// get the version from the build info (when installed with go install)
|
||||||
v, ok := debug.ReadBuildInfo()
|
if v, ok := debug.ReadBuildInfo(); ok {
|
||||||
if ok {
|
|
||||||
return v.Main.Version + "-" + v.GoVersion
|
return v.Main.Version + "-" + v.GoVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user