func (v *Version) Patch() int64 {
	return v.patch
}
Patch returns the patch version.
package semver
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"regexp"
	"strconv"
	"strings"
)
var versionRegex *regexp.Regexp
var validPrereleaseRegex *regexp.Regexp
var (
	ErrInvalidSemVer = errors.New("Invalid Semantic Version")
	ErrInvalidMetadata = errors.New("Invalid Metadata string")
	ErrInvalidPrerelease = errors.New("Invalid Prerelease string")
)
const SemVerRegex string = `v?([0-9]+)(\.[0-9]+)?(\.[0-9]+)?` +
	`(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` +
	`(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?`
const ValidPrerelease string = `^([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*)`
type Version struct {
	major, minor, patch int64
	pre                 string
	metadata            string
	original            string
}
func init() {
	versionRegex = regexp.MustCompile("^" + SemVerRegex + "$")
	validPrereleaseRegex = regexp.MustCompile(ValidPrerelease)
}
func NewVersion(v string) (*Version, error) {
	m := versionRegex.FindStringSubmatch(v)
	if m == nil {
		return nil, ErrInvalidSemVer
	}
	sv := &Version{
		metadata: m[8],
		pre:      m[5],
		original: v,
	}
	var temp int64
	temp, err := strconv.ParseInt(m[1], 10, 64)
	if err != nil {
		return nil, fmt.Errorf("Error parsing version segment: %s", err)
	}
	sv.major = temp
	if m[2] != "" {
		temp, err = strconv.ParseInt(strings.TrimPrefix(m[2], "."), 10, 64)
		if err != nil {
			return nil, fmt.Errorf("Error parsing version segment: %s", err)
		}
		sv.minor = temp
	} else {
		sv.minor = 0
	}
	if m[3] != "" {
		temp, err = strconv.ParseInt(strings.TrimPrefix(m[3], "."), 10, 64)
		if err != nil {
			return nil, fmt.Errorf("Error parsing version segment: %s", err)
		}
		sv.patch = temp
	} else {
		sv.patch = 0
	}
	return sv, nil
}
func MustParse(v string) *Version {
	sv, err := NewVersion(v)
	if err != nil {
		panic(err)
	}
	return sv
}
func (v *Version) String() string {
	var buf bytes.Buffer
	fmt.Fprintf(&buf, "%d.%d.%d", v.major, v.minor, v.patch)
	if v.pre != "" {
		fmt.Fprintf(&buf, "-%s", v.pre)
	}
	if v.metadata != "" {
		fmt.Fprintf(&buf, "+%s", v.metadata)
	}
	return buf.String()
}
func (v *Version) Original() string {
	return v.original
}
func (v *Version) Major() int64 {
	return v.major
}
func (v *Version) Minor() int64 {
	return v.minor
}