31 lines
621 B
Go
31 lines
621 B
Go
package ver
|
|
|
|
import (
|
|
"golang.org/x/mod/semver"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
var Ver string
|
|
|
|
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 {
|
|
if Ver == "" {
|
|
Ver = os.Getenv("BUILD_VER")
|
|
}
|
|
return Ver
|
|
}
|