replaycli-go/ver/lib.go

31 lines
621 B
Go
Raw Normal View History

2021-11-11 14:07:20 +00:00
package ver
import (
"golang.org/x/mod/semver"
"log"
"os"
)
2021-11-14 13:31:07 +00:00
var Ver string
2021-11-11 14:07:20 +00:00
func EnsureVer(v string) {
build := os.Getenv("BUILD_VER")
if build == "" {
log.Printf("No BUILD_VER found - skipping verification")
return
}
if semver.Compare(build, v) < 0 {
log.Printf("Replay version is %s, lower than required. Should be minimum %s - aborting", build, v)
os.Exit(0)
}
if semver.Major(build) != semver.Major(v) {
log.Printf("Replay major version is %s, different from feature requirement: %s - aborting", build, v)
}
}
func Get() string {
2021-11-14 13:31:07 +00:00
if Ver == "" {
Ver = os.Getenv("BUILD_VER")
}
return Ver
2021-11-11 14:07:20 +00:00
}