MCPcopy
hub / github.com/tailscale/tailscale / mustGetGoModVersion

Function mustGetGoModVersion

version_test.go:59–85  ·  view source on GitHub ↗
(t *testing.T, includePatchVersion bool)

Source from the content-addressed store, hash-verified

57}
58
59func mustGetGoModVersion(t *testing.T, includePatchVersion bool) string {
60 t.Helper()
61
62 goModBytes, err := os.ReadFile("go.mod")
63 if err != nil {
64 t.Fatal(err)
65 }
66
67 modFile, err := modfile.Parse("go.mod", goModBytes, nil)
68 if err != nil {
69 t.Fatal(err)
70 }
71
72 if modFile.Go == nil {
73 t.Fatal("no Go version found in go.mod")
74 }
75
76 version := modFile.Go.Version
77
78 parts := strings.Split(version, ".")
79 if !includePatchVersion {
80 if len(parts) >= 2 {
81 version = parts[0] + "." + parts[1]
82 }
83 }
84 return version
85}

Callers 2

TestDockerfileVersionFunction · 0.85
TestGoVersionFunction · 0.85

Calls 5

SplitMethod · 0.80
HelperMethod · 0.65
ReadFileMethod · 0.65
FatalMethod · 0.65
ParseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…