本文整理汇总了Golang中github.com/blang/semver.Version.Validate方法的典型用法代码示例。如果您正苦于以下问题:Golang Version.Validate方法的具体用法?Golang Version.Validate怎么用?Golang Version.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/blang/semver.Version
的用法示例。
在下文中一共展示了Version.Validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: New
// Create and initialize a new application. This is a front gate for
// the framework, since you should start by creating a new app struct.
// Every application should have a valid name (tag) and a version. So
// this function makes sure they have been passed and are all valid.
// Generally, you should not be creating more than one application.
func New(name, version string) *App {
var room = make(map[string]interface{})
const url = "https://github.com/ts33kr/boot"
const ename = "name is not of correct format"
const eversion = "version is not valid semver"
pattern := regexp.MustCompile("^[a-zA-Z0-9-_]+$")
var parsed semver.Version = semver.MustParse(version)
if !pattern.MatchString(name) {
panic(ename)
}
if parsed.Validate() != nil {
panic(eversion)
}
application := &App{Name: name, Version: parsed}
application.Storage = Storage{Container: room}
application.CronEngine = cron.New() // create CRON
application.Servers = make(map[string]*http.Server)
application.Reference = shortuuid.New() // V4
application.Providers = make([]*Provider, 0)
application.Services = make([]*Service, 0)
application.TimeLayout = time.RFC850
application.Namespace = url // set
return application // prepared app
}