示例#1
0
func main() {
	vA, err := semver.NewVersion(os.Args[1])
	if err != nil {
		fmt.Println(err.Error())
	}
	vB, err := semver.NewVersion(os.Args[2])
	if err != nil {
		fmt.Println(err.Error())
	}

	fmt.Printf("%s < %s == %t\n", vA, vB, vA.LessThan(*vB))
}
示例#2
0
文件: version.go 项目: paulczar/fleet
func init() {
	sv, err := semver.NewVersion(Version)
	if err != nil {
		panic("bad version string!")
	}
	SemVersion = *sv
}
示例#3
0
func newFakeRegistryForCheckVersion(v string) registry.Registry {
	sv, err := semver.NewVersion(v)
	if err != nil {
		panic(err)
	}

	reg := registry.NewFakeRegistry()
	reg.SetLatestVersion(*sv)

	return reg
}
示例#4
0
// GetLatestVersion attempts to retrieve the latest version of fleet that has
// been registered in the Registry. It returns the version if it can be
// determined (or nil otherwise), and any error encountered.
func (r *EtcdRegistry) GetLatestVersion() (*semver.Version, error) {
	machs, err := r.GetActiveMachines()
	if err != nil {
		if isKeyNotFound(err) {
			err = nil
		}
		return nil, err
	}
	var lv *semver.Version
	for _, m := range machs {
		v, err := semver.NewVersion(m.Version)
		if err != nil {
			continue
		} else if lv == nil || lv.LessThan(*v) {
			lv = v
		}
	}
	return lv, nil
}