MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / CheckVersion

Method CheckVersion

tools/mage/go.go:102–124  ·  view source on GitHub ↗

CheckVersion checks the installed Go version against the minimum version we support.

()

Source from the content-addressed store, hash-verified

100
101// CheckVersion checks the installed Go version against the minimum version we support.
102func (Go) CheckVersion() error {
103 if mg.Verbose() {
104 fmt.Println("Checking Go version")
105 }
106 versionStr, err := outputGo("version")
107 if err != nil {
108 return err
109 }
110 version := strings.Split(strings.TrimPrefix(strings.Fields(versionStr)[2], "go"), ".")
111 major, _ := strconv.Atoi(version[0])
112 minor, _ := strconv.Atoi(version[1])
113 var patch int
114 if len(version) > 2 {
115 patch, _ = strconv.Atoi(version[2])
116 }
117 current := semver.Version{Major: uint64(major), Minor: uint64(minor), Patch: uint64(patch)}
118 min, _ := semver.Parse(minGoVersion)
119 if current.LT(min) {
120 return fmt.Errorf("Your version of Go (%s) is not supported. Please install Go %s or later",
121 versionStr, minGoVersion)
122 }
123 return nil
124}
125
126var goPackageDirs []string
127

Callers

nothing calls this directly

Calls 5

outputGoFunction · 0.85
TrimPrefixMethod · 0.80
FieldsMethod · 0.65
ParseMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected