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
}
Set parses and updates v from the given version string. Implements flag.Value
package semver
import (
	"bytes"
	"errors"
	"fmt"
	"regexp"
	"strconv"
	"strings"
)
type Version struct {
	Major      int64
	Minor      int64
	Patch      int64
	PreRelease PreRelease
	Metadata   string
}
type PreRelease string
func splitOff(input *string, delim string) (val string) {
	parts := strings.SplitN(*input, delim, 2)
	if len(parts) == 2 {
		*input = parts[0]
		val = parts[1]
	}
	return val
}
func New(version string) *Version {
	return Must(NewVersion(version))
}
func NewVersion(version string) (*Version, error) {
	v := Version{}
	if err := v.Set(version); err != nil {
		return nil, err
	}
	return &v, nil
}
func Must(v *Version, err error) *Version {
	if err != nil {
		panic(err)
	}
	return v
}