forked from toolshed/abra
chore: vendor
This commit is contained in:
35
vendor/gotest.tools/v3/internal/source/version.go
vendored
Normal file
35
vendor/gotest.tools/v3/internal/source/version.go
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GoVersionLessThan returns true if runtime.Version() is semantically less than
|
||||
// version major.minor. Returns false if a release version can not be parsed from
|
||||
// runtime.Version().
|
||||
func GoVersionLessThan(major, minor int64) bool {
|
||||
version := runtime.Version()
|
||||
// not a release version
|
||||
if !strings.HasPrefix(version, "go") {
|
||||
return false
|
||||
}
|
||||
version = strings.TrimPrefix(version, "go")
|
||||
parts := strings.Split(version, ".")
|
||||
if len(parts) < 2 {
|
||||
return false
|
||||
}
|
||||
rMajor, err := strconv.ParseInt(parts[0], 10, 32)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if rMajor != major {
|
||||
return rMajor < major
|
||||
}
|
||||
rMinor, err := strconv.ParseInt(parts[1], 10, 32)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return rMinor < minor
|
||||
}
|
Reference in New Issue
Block a user