func (v *Version)ParseVersion(version string) (err error) {
	parsedResult := versionRegExp.FindAllStringSubmatch(version, -1)
	if len(parsedResult) != 1 {
		err = errors.Errorf("Invalid version %s", version)
		return
	}
	if len(parsedResult[0]) != 7 {
		err = errors.Errorf("Invalid version %s", version)
		return
	}
	v.Prefix = parsedResult[0][1]
	v.Major = v.intOrZero(parsedResult[0][2])
	v.Minor = v.intOrZero(parsedResult[0][3])
	v.Maintenance = v.intOrZero(parsedResult[0][5])
	v.Suffix = parsedResult[0][6]
	return
}
Parse the version and return it as a Version object
package model
import (
	"fmt"
	"github.com/pkg/errors"
	"regexp"
	"strconv"
)
type Version struct {
	Prefix       string
	Major        int
	Minor        int
	Maintenance  int
	Suffix       string
	BuildDate    string
	MinGoVersion string
}
var frameworkCompatibleRangeList = [][]string{
	{"0.0.0", "0.20.0"},  
	{"0.19.99", "0.30.0"},  
	{"1.0.0", "1.9.0"},  
}
var versionRegExp = regexp.MustCompile(`([^\d]*)?([0-9]*)\.([0-9]*)(\.([0-9]*))?(.*)`)
func ParseVersion(version string) (v *Version, err error) {
	v = &Version{}
	return v, v.ParseVersion(version)
}