MCPcopy
hub / github.com/cilium/cilium / readGoModGoVersion

Function readGoModGoVersion

tools/dev-doctor/rootcmd.go:34–54  ·  view source on GitHub ↗
(rootDir string)

Source from the content-addressed store, hash-verified

32}
33
34func readGoModGoVersion(rootDir string) (*semver.Version, error) {
35 goModFile := "go.mod"
36 path := filepath.Join(rootDir, goModFile)
37 data, err := os.ReadFile(path)
38 if err != nil {
39 return nil, err
40 }
41 mod, err := modfile.Parse(goModFile, data, nil)
42 if err != nil {
43 return nil, err
44 }
45
46 if mod.Go == nil {
47 return nil, fmt.Errorf("no go statement found in %s", path)
48 }
49 ver, err := semver.ParseTolerant(mod.Go.Version)
50 if err != nil {
51 return nil, err
52 }
53 return &ver, nil
54}
55
56func rootCmdRun(cmd *cobra.Command, args []string) {
57 rootDir := goPath() + "/src/github.com/cilium/cilium"

Callers 1

rootCmdRunFunction · 0.85

Calls 2

ParseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…