func()

in src/version/versionutil.go [39:64]


func (thisVersion version) compare(otherVersion version) (int, error) {
	if len(thisVersion.version) != len(otherVersion.version) {
		return -1, fmt.Errorf("length mismatch for versions %s and %s", thisVersion.version, otherVersion.version)
	}

	var (
		thisVersionSlice  int
		otherVersionSlice int
		err               error
	)
	for i := range thisVersion.version {
		if thisVersionSlice, err = strconv.Atoi(thisVersion.version[i]); err != nil {
			return -1, err
		}
		if otherVersionSlice, err = strconv.Atoi(otherVersion.version[i]); err != nil {
			return -1, err
		}

		if thisVersionSlice > otherVersionSlice {
			return 1, nil
		} else if thisVersionSlice < otherVersionSlice {
			return -1, nil
		}
	}
	return 0, nil
}