MCPcopy
hub / github.com/google/cadvisor / ParseVersion

Function ParseVersion

container/docker/docker.go:185–200  ·  view source on GitHub ↗
(versionString string, regex *regexp.Regexp, length int)

Source from the content-addressed store, hash-verified

183}
184
185func ParseVersion(versionString string, regex *regexp.Regexp, length int) ([]int, error) {
186 matches := regex.FindAllStringSubmatch(versionString, -1)
187 if len(matches) != 1 {
188 return nil, fmt.Errorf("version string \"%v\" doesn't match expected regular expression: \"%v\"", versionString, regex.String())
189 }
190 versionStringArray := matches[0][1:]
191 versionArray := make([]int, length)
192 for index, versionStr := range versionStringArray {
193 version, err := strconv.Atoi(versionStr)
194 if err != nil {
195 return nil, fmt.Errorf("error while parsing \"%v\" in \"%v\"", versionStr, versionString)
196 }
197 versionArray[index] = version
198 }
199 return versionArray, nil
200}

Callers 4

RegisterFunction · 0.85
ValidateInfoFunction · 0.85
APIVersionFunction · 0.85

Calls 2

ErrorfMethod · 0.80
StringMethod · 0.65

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…