MCPcopy Index your code
hub / github.com/docker/docker-agent / versionFromDir

Function versionFromDir

lint/configpath.go:17–26  ·  view source on GitHub ↗

Helpers shared by the cops in this package. They centralise the parsing of pkg/config/ / paths and pkg/config/vN import paths, so each cop can focus on its rule rather than on regular expressions. versionFromDir parses a "vN" directory name and returns N. Returns false for any other name (latest

(dir string)

Source from the content-addressed store, hash-verified

15// versionFromDir parses a "vN" directory name and returns N. Returns false
16// for any other name (latest, types, vendor, ...).
17func versionFromDir(dir string) (int, bool) {
18 if len(dir) < 2 || dir[0] != 'v' {
19 return 0, false
20 }
21 n, err := strconv.Atoi(dir[1:])
22 if err != nil {
23 return 0, false
24 }
25 return n, true
26}
27
28// versionFromImport returns N if importPath ends with "pkg/config/vN".
29// Re-uses [versionFromDir] for the vN suffix, so the two helpers cannot

Callers 5

versionFromImportFunction · 0.85
scanHighestVNFunction · 0.85
versionPackagesOnDiskFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected