agent/utils/compare_versions.go
func compareSemver(lhs, rhs semver) int {
	if lhs.major < rhs.major {
		return -1
	}
	if lhs.major > rhs.major {
		return 1
	}
	if lhs.minor < rhs.minor {
		return -1
	}
	if lhs.minor > rhs.minor {
		return 1
	}
	if lhs.patch < rhs.patch {
		return -1
	}
	if lhs.patch > rhs.patch {
		return 1
	}
	if lhs.preReleaseVersion != "" && rhs.preReleaseVersion == "" {
		return -1
	}
	if lhs.preReleaseVersion == "" && rhs.preReleaseVersion != "" {
		return 1
	}
	if lhs.preReleaseVersion < rhs.preReleaseVersion {
		return -1
	}
	if lhs.preReleaseVersion > rhs.preReleaseVersion {
		return 1
	}
	return 0
}
func compareSemver(lhs, rhs semver) int {
	if lhs.major < rhs.major {
		return -1
	}
	if lhs.major > rhs.major {
		return 1
	}
	if lhs.minor < rhs.minor {
		return -1
	}
	if lhs.minor > rhs.minor {
		return 1
	}
	if lhs.patch < rhs.patch {
		return -1
	}
	if lhs.patch > rhs.patch {
		return 1
	}
	if lhs.preReleaseVersion != "" && rhs.preReleaseVersion == "" {
		return -1
	}
	if lhs.preReleaseVersion == "" && rhs.preReleaseVersion != "" {
		return 1
	}
	if lhs.preReleaseVersion < rhs.preReleaseVersion {
		return -1
	}
	if lhs.preReleaseVersion > rhs.preReleaseVersion {
		return 1
	}
	return 0
}
func compareSemver ( lhs , rhs semver ) int { if lhs . major < rhs . major { return - 1 } if lhs . major > rhs . major { return 1 } if lhs . minor < rhs . minor { return - 1 } if lhs . minor > rhs . minor { return 1 } if lhs . patch < rhs . patch { return - 1 } if lhs . patch > rhs . patch { return 1 } if lhs . preReleaseVersion != " " && rhs . preReleaseVersion == " " { return - 1 } if lhs . preReleaseVersion == " " && rhs . preReleaseVersion != " " { return 1 } if lhs . preReleaseVersion < rhs . preReleaseVersion { return - 1 } if lhs . preReleaseVersion > rhs . preReleaseVersion { return 1 } return 0 }
// compareSemver compares two semvers, 'lhs' and 'rhs', and returns -1 if lhs is less
// than rhs, 0 if they are equal, and 1 lhs is greater than rhs
compareSemver compares two semvers lhs and rhs and returns - 1 if lhs is less than rhs 0 if they are equal and 1 lhs is greater than rhs