func (v *Version) Set(version string) error {
	metadata := splitOff(&version, "+")
	preRelease := PreRelease(splitOff(&version, "-"))
	dotParts := strings.SplitN(version, ".", 3)

	if len(dotParts) != 3 {
		return fmt.Errorf("%s is not in dotted-tri format", version)
	}

	if err := validateIdentifier(string(preRelease)); err != nil {
		return fmt.Errorf("failed to validate pre-release: %v", err)
	}

	if err := validateIdentifier(metadata); err != nil {
		return fmt.Errorf("failed to validate metadata: %v", err)
	}

	parsed := make([]int64, 3, 3)

	for i, v := range dotParts[:3] {
		val, err := strconv.ParseInt(v, 10, 64)
		parsed[i] = val
		if err != nil {
			return err
		}
	}

	v.Metadata = metadata
	v.PreRelease = preRelease
	v.Major = parsed[0]
	v.Minor = parsed[1]
	v.Patch = parsed[2]
	return nil
}
func (v *Version) Set(version string) error {
	metadata := splitOff(&version, "+")
	preRelease := PreRelease(splitOff(&version, "-"))
	dotParts := strings.SplitN(version, ".", 3)

	if len(dotParts) != 3 {
		return fmt.Errorf("%s is not in dotted-tri format", version)
	}

	if err := validateIdentifier(string(preRelease)); err != nil {
		return fmt.Errorf("failed to validate pre-release: %v", err)
	}

	if err := validateIdentifier(metadata); err != nil {
		return fmt.Errorf("failed to validate metadata: %v", err)
	}

	parsed := make([]int64, 3, 3)

	for i, v := range dotParts[:3] {
		val, err := strconv.ParseInt(v, 10, 64)
		parsed[i] = val
		if err != nil {
			return err
		}
	}

	v.Metadata = metadata
	v.PreRelease = preRelease
	v.Major = parsed[0]
	v.Minor = parsed[1]
	v.Patch = parsed[2]
	return nil
}
func ( v * Version ) Set ( version string ) error { metadata := splitOff ( & version , " " ) preRelease := PreRelease ( splitOff ( & version , " " ) ) dotParts := strings . SplitN ( version , " " , 3 ) if len ( dotParts ) != 3 { return fmt . Errorf ( " " , version ) } if err := validateIdentifier ( string ( preRelease ) ) ; err != nil { return fmt . Errorf ( " " , err ) } if err := validateIdentifier ( metadata ) ; err != nil { return fmt . Errorf ( " " , err ) } parsed := make ( [ ] int64 , 3 , 3 ) for i , v := range dotParts [ : 3 ] { val , err := strconv . ParseInt ( v , 10 , 64 ) parsed [ i ] = val if err != nil { return err } } v . Metadata = metadata v . PreRelease = preRelease v . Major = parsed [ 0 ] v . Minor = parsed [ 1 ] v . Patch = parsed [ 2 ] return nil }
// Set parses and updates v from the given version string. Implements flag.Value
Set parses and updates v from the given version string . Implements flag . Value