CheckVersion checks the installed Go version against the minimum version we support.
()
| 100 | |
| 101 | // CheckVersion checks the installed Go version against the minimum version we support. |
| 102 | func (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 | |
| 126 | var goPackageDirs []string |
| 127 |
nothing calls this directly
no test coverage detected