MCPcopy
hub / github.com/perkeep/perkeep / verifyGoVersion

Function verifyGoVersion

make.go:333–363  ·  view source on GitHub ↗

verifyGoVersion runs "go version" and parses the output. If the version is acceptable a check for gopherjs versions are also done. If problems are found a message is logged and we abort.

()

Source from the content-addressed store, hash-verified

331// acceptable a check for gopherjs versions are also done. If problems
332// are found a message is logged and we abort.
333func verifyGoVersion() {
334 _, err := exec.LookPath("go")
335 if err != nil {
336 log.Fatalf("Go doesn't appear to be installed ('go' isn't in your PATH). Install Go 1.%d or newer.", goVersionMinor)
337 }
338 out, err := exec.Command("go", "version").Output()
339 if err != nil {
340 log.Fatalf("Error checking Go version with the 'go' command: %v", err)
341 }
342
343 version := string(out)
344
345 // Handle non-versioned binaries
346 // ex: "go version devel +c26fac8 Thu Feb 15 21:41:39 2018 +0000 linux/amd64"
347 if strings.HasPrefix(version, "go version devel ") {
348 return
349 }
350
351 m := validVersionRx.FindStringSubmatch(version)
352 if m == nil {
353 log.Fatalf("Unexpected output while checking 'go version': %q", version)
354 }
355 minorVersion, err := strconv.Atoi(m[1])
356 if err != nil {
357 log.Fatalf("Unexpected error while parsing version string %q: %v", m[1], err)
358 }
359
360 if minorVersion < goVersionMinor {
361 log.Fatalf("Your version of Go (%s) is too old. Perkeep requires Go 1.%d or later.", string(out), goVersionMinor)
362 }
363}
364
365func failIfCamlistoreOrgDir() {
366 dir, _ := os.Getwd()

Callers 1

mainFunction · 0.85

Calls 4

HasPrefixMethod · 0.80
LookPathMethod · 0.65
FatalfMethod · 0.65
CommandMethod · 0.65

Tested by

no test coverage detected