replaycli-go/ver/lib.go

27 lines
590 B
Go

package ver
import (
"golang.org/x/mod/semver"
"log"
"os"
)
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 {
build := os.Getenv("BUILD_VER")
return build
}