• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang semver.Make函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/blang/semver.Make函数的典型用法代码示例。如果您正苦于以下问题:Golang Make函数的具体用法?Golang Make怎么用?Golang Make使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Make函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetUpdatePackage

// GetUpdatePackage returns an update package for the instance/application
// provided. The instance details and the application it's running will be
// registered in CoreRoller (or updated if it's already registered).
func (api *API) GetUpdatePackage(instanceID, instanceIP, instanceVersion, appID, groupID string) (*Package, error) {
	instance, err := api.RegisterInstance(instanceID, instanceIP, instanceVersion, appID, groupID)
	if err != nil {
		return nil, ErrRegisterInstanceFailed
	}

	if instance.Application.Status.Valid {
		switch int(instance.Application.Status.Int64) {
		case InstanceStatusUpdateGranted, InstanceStatusDownloading, InstanceStatusDownloaded, InstanceStatusInstalled:
			return nil, ErrUpdateInProgressOnInstance
		}
	}

	group, err := api.GetGroup(groupID)
	if err != nil {
		return nil, err
	}

	if group.Channel == nil || group.Channel.Package == nil {
		_ = api.newGroupActivityEntry(activityPackageNotFound, activityWarning, "0.0.0", appID, groupID)
		return nil, ErrNoPackageFound
	}

	for _, blacklistedChannelID := range group.Channel.Package.ChannelsBlacklist {
		if blacklistedChannelID == group.Channel.ID {
			return nil, ErrNoUpdatePackageAvailable
		}
	}

	instanceSemver, _ := semver.Make(instanceVersion)
	packageSemver, _ := semver.Make(group.Channel.Package.Version)
	if !instanceSemver.LT(packageSemver) {
		return nil, ErrNoUpdatePackageAvailable
	}

	updatesStats, err := api.getGroupUpdatesStats(group)
	if err != nil {
		return nil, ErrGetUpdatesStatsFailed
	}

	if err := api.enforceRolloutPolicy(instance, group, updatesStats); err != nil {
		return nil, err
	}

	if err := api.grantUpdate(instance.ID, appID, group.Channel.Package.Version); err != nil {
		return nil, ErrGrantingUpdate
	}

	if updatesStats.UpdatesToCurrentVersionGranted == 0 {
		_ = api.newGroupActivityEntry(activityRolloutStarted, activityInfo, group.Channel.Package.Version, appID, group.ID)
	}

	if !group.RolloutInProgress {
		_ = api.setGroupRolloutInProgress(groupID, true)
	}

	_ = api.updateInstanceStatus(instance.ID, appID, InstanceStatusUpdateGranted)

	return group.Channel.Package, nil
}
开发者ID:coreroller,项目名称:coreroller,代码行数:63,代码来源:updates.go


示例2: isUpgradeAvailable

func isUpgradeAvailable() (bool, string) {
	gh := buildGithubClient()
	release, response, err := gh.Repositories.GetLatestRelease("getcarina", "dvm")
	if err != nil {
		warnWhenRateLimitExceeded(err, response)
		writeWarning("Unable to query the latest dvm release from GitHub:")
		writeWarning("%s", err)
		return false, ""
	}
	if response.StatusCode != 200 {
		writeWarning("Unable to query the latest dvm release from GitHub (Status %s):", response.StatusCode)
		return false, ""
	}

	currentVersion, err := semver.Make(dvmVersion)
	if err != nil {
		writeWarning("Unable to parse the current dvm version as a semantic version!")
		writeWarning("%s", err)
		return false, ""
	}
	latestVersion, err := semver.Make(*release.TagName)
	if err != nil {
		writeWarning("Unable to parse the latest dvm version as a semantic version!")
		writeWarning("%s", err)
		return false, ""
	}

	return latestVersion.Compare(currentVersion) > 0, *release.TagName
}
开发者ID:getcarina,项目名称:dvm,代码行数:29,代码来源:dvm-helper.go


示例3: Less

func (a BugListByMilestone) Less(i, j int) bool {
	iMS := a[i].Milestone()
	jMS := a[j].Milestone()
	// If there's a "v" at the start, strip it out
	// before doing any comparisons of semantic
	// versions
	if len(iMS) > 1 && iMS[0] == "v"[0] {
		iMS = iMS[1:]
	}
	if len(jMS) > 1 && jMS[0] == "v"[0] {
		jMS = jMS[1:]
	}
	// First try semantic versioning comparison
	iVer, iVerErr := semver.Make(iMS)
	jVer, jVerErr := semver.Make(jMS)
	if iVerErr == nil && jVerErr == nil {
		return iVer.LT(jVer)
	}

	// Next try floating point comparison as an
	// approximation of real number comparison..
	iFloat, iVerErr := strconv.ParseFloat(iMS, 32)
	jFloat, jVerErr := strconv.ParseFloat(jMS, 32)
	if iVerErr == nil && jVerErr == nil {
		return iFloat < jFloat
	}

	// Finally, just use a normal string collation
	return iMS < jMS
}
开发者ID:Komosa,项目名称:bug,代码行数:30,代码来源:Roadmap.go


示例4: latestTag

func latestTag(client *github.Client, org, name string) string {
	opt := &github.ListOptions{PerPage: 100}

	latest, err := semver.Make("0.0.1")
	if err != nil {
		panic(err)
	}

	for {
		newTags, resp, err := client.Repositories.ListTags(org, name, opt)
		if err != nil {
			panic(err)
		}

		for _, tag := range newTags {
			version, err := semver.Make(*tag.Name)
			if err != nil {
				continue
			}

			if version.Compare(latest) > 0 {
				latest = version
			}
		}

		if resp.NextPage == 0 {
			break
		}

		opt.Page = resp.NextPage
	}

	return latest.String()
}
开发者ID:segmentio,项目名称:go-release,代码行数:34,代码来源:main.go


示例5: greater

func greater(s1, s2 string) bool {
	v1, err1 := semver.Make(s1)
	v2, err2 := semver.Make(s2)
	if err1 != nil || err2 != nil {
		return s1 > s2
	}
	return v1.Compare(v2) > 0
}
开发者ID:matteosuppo,项目名称:arduino-install-cores,代码行数:8,代码来源:main.go


示例6: compareVersion

// @return result.Result<VersionStatus, error>
func compareVersion(toolVersion, repoVersion string) result.Result {
	errorMsg := fmt.Sprintf(toolInvalidError, toolVersion, repoVersion)
	invalidErr := result.NewFailure(errors.New(errorMsg))
	vt := result.NewResult(semver.Make(toolVersion)).RecoverWith(invalidErr)
	vr := result.NewResult(semver.Make(repoVersion)).RecoverWith(invalidErr)
	return result.Combine(func(values ...interface{}) result.Result {
		vt, vr := values[0].(semver.Version), values[1].(semver.Version)
		return comparisonStatus(vt.Compare(vr))
	}, vt, vr)
}
开发者ID:git-comment,项目名称:git-comment,代码行数:11,代码来源:version.go


示例7: getLatestVersion

func (m *Manifest) getLatestVersion() string {
	latestVersion, _ := semver.Make(NoVersion)

	for _, version := range m.Versions {
		if currentVersion, err := semver.Make(version.Version); err != nil {
			continue
		} else if latestVersion.LT(currentVersion) {
			latestVersion = currentVersion
		}
	}

	return latestVersion.String()
}
开发者ID:layer3switch,项目名称:packer-post-processor-vagrant-s3,代码行数:13,代码来源:manifest.go


示例8: updateSelf

func updateSelf() error {
	up := update.New()
	if err := up.CanUpdate(); err != nil {
		logger.Warn("msg", "Can't update this binary!", "error", err)
		return err
	}

	up, err := up.VerifySignatureWithPEM([]byte(publicKey))
	if err != nil {
		logger.Error("msg", "Failed to parse public key!", "error", err)
		return err
	}
	// check for the update
	r, err := (&check.Params{
		AppId:      "ap_XZ-6toIU_0Bf0BJFDVvDpV9IVD",
		AppVersion: version,
		Channel:    "latest",
	}).CheckForUpdate(updateURI, up)
	if err != nil {
		if err == check.NoUpdateAvailable {
			logger.Info("msg", "No update available.")
			return nil
		}
		logger.Error("msg", "Checking for update", "error", err)
		return err
	}
	v1, err := semver.Make(version)
	if err != nil {
		logger.Error("msg", "Bad version", "current", version, "error", err)
		return err
	}
	v2, err := semver.Make(r.Version)
	if err != nil {
		logger.Error("msg", "Bad version", "new", r.Version, "error", err)
		return err
	}
	if !v2.GTE(v1) {
		logger.Warn("msg", "Version mismatch", "current", v1, "new", v2)
		return nil
	}

	// apply the update
	if err, _ = r.Update(); err != nil {
		logger.Error("msg", "Update failed", "error", err)
		return err
	}
	logger.Info("msg", "Update successful, exiting.")
	os.Exit(0)
	return nil
}
开发者ID:thanzen,项目名称:agostle,代码行数:50,代码来源:update.go


示例9: IsMinCliVersion

func (cmd *CliRpcCmd) IsMinCliVersion(version string, retVal *bool) error {
	actualVersion, err := semver.Make(cf.Version)
	if err != nil {
		return err
	}

	requiredVersion, err := semver.Make(version)
	if err != nil {
		return err
	}

	*retVal = actualVersion.GTE(requiredVersion)

	return nil
}
开发者ID:seetharamireddy540,项目名称:cli,代码行数:15,代码来源:cli_rpc_server.go


示例10: IsMountainLion

func IsMountainLion() bool {
	osver, err := semver.Make(OSRelease())
	if err != nil {
		return false
	}
	return runtime.GOOS == "darwin" && osver.GTE(mountainLionVer)
}
开发者ID:narma,项目名称:go-notifier,代码行数:7,代码来源:os_version.go


示例11: Requirements

func (cmd *UnbindRouteService) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement {
	if len(fc.Args()) != 2 {
		cmd.ui.Failed(T("Incorrect Usage. Requires DOMAIN and SERVICE_INSTANCE as arguments\n\n") + commandregistry.Commands.CommandUsage("unbind-route-service"))
	}

	serviceName := fc.Args()[1]
	cmd.serviceInstanceReq = requirementsFactory.NewServiceInstanceRequirement(serviceName)

	domainName := fc.Args()[0]
	cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName)

	minAPIVersion, err := semver.Make("2.51.0")
	if err != nil {
		panic(err.Error())
	}

	minAPIVersionRequirement := requirementsFactory.NewMinAPIVersionRequirement(
		"unbind-route-service",
		minAPIVersion,
	)

	reqs := []requirements.Requirement{
		minAPIVersionRequirement,
		requirementsFactory.NewLoginRequirement(),
		cmd.domainReq,
		cmd.serviceInstanceReq,
	}
	return reqs
}
开发者ID:Reejoshi,项目名称:cli,代码行数:29,代码来源:unbind_route_service.go


示例12: IsWin8

func IsWin8() bool {
	osver, err := semver.Make(OSRelease())
	if err != nil {
		return false
	}
	return runtime.GOOS == "windows" && osver.GTE(win8ver)
}
开发者ID:narma,项目名称:go-notifier,代码行数:7,代码来源:os_version.go


示例13: getNextVersion

func (m *Manifest) getNextVersion() string {
	latestVersion, _ := semver.Make(m.getLatestVersion())
	latestVersion.Minor++
	latestVersion.Patch = 0

	return latestVersion.String()
}
开发者ID:layer3switch,项目名称:packer-post-processor-vagrant-s3,代码行数:7,代码来源:manifest.go


示例14: getLatestVersionFromURL

func getLatestVersionFromURL(url string) (semver.Version, error) {
	r, err := GetAllVersionsFromURL(url)
	if err != nil {
		return semver.Version{}, err
	}
	return semver.Make(strings.TrimPrefix(r[0].Name, version.VersionPrefix))
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:7,代码来源:notify.go


示例15: Execute

func (r MaxAPIVersionRequirement) Execute() bool {
	if r.config.ApiVersion() == "" {
		r.ui.Failed(T("Unable to determine CC API Version. Please log in again."))
	}

	apiVersion, err := semver.Make(r.config.ApiVersion())
	if err != nil {
		r.ui.Failed(T("Unable to parse CC API Version '{{.APIVersion}}'", map[string]interface{}{
			"APIVersion": r.config.ApiVersion(),
		}))

		return false
	}

	if apiVersion.GT(r.maximumVersion) {
		r.ui.Failed(T(`{{.Feature}} only works up to CF API version {{.MaximumVersion}}. Your target is {{.ApiVersion}}.`,
			map[string]interface{}{
				"ApiVersion":     r.config.ApiVersion(),
				"Feature":        r.feature,
				"MaximumVersion": r.maximumVersion.String(),
			}))

		return false
	}

	return true
}
开发者ID:jmcabandara,项目名称:cli,代码行数:27,代码来源:max_api_version.go


示例16: Requirements

func (cmd *UnmapRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement {
	if len(fc.Args()) != 2 {
		cmd.ui.Failed(T("Incorrect Usage. Requires app_name, domain_name as arguments\n\n") + command_registry.Commands.CommandUsage("unmap-route"))
	}

	domainName := fc.Args()[1]

	cmd.appReq = requirementsFactory.NewApplicationRequirement(fc.Args()[0])
	cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName)

	requiredVersion, err := semver.Make("2.36.0")
	if err != nil {
		panic(err.Error())
	}

	var reqs []requirements.Requirement

	if fc.String("path") != "" {
		reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--path'", requiredVersion))
	}

	reqs = append(reqs, []requirements.Requirement{
		requirementsFactory.NewLoginRequirement(),
		cmd.appReq,
		cmd.domainReq,
	}...)

	return reqs
}
开发者ID:cloudfoundry-incubator,项目名称:Diego-Enabler,代码行数:29,代码来源:unmap_route.go


示例17: Execute

func (r MinAPIVersionRequirement) Execute() bool {
	if r.config.ApiVersion() == "" {
		r.ui.Failed(T("Unable to determine CC API Version. Please log in again."))
	}

	apiVersion, err := semver.Make(r.config.ApiVersion())
	if err != nil {
		r.ui.Failed(T("Unable to parse CC API Version '{{.APIVersion}}'", map[string]interface{}{
			"APIVersion": r.config.ApiVersion(),
		}))
	}

	if apiVersion.LT(r.requiredVersion) {
		r.ui.Failed(T(`Current CF CLI version {{.Version}}
	Current CF API version {{.ApiVersion}}
	To use the {{.CommandName}} feature, you need to upgrade the CF API to at least {{.RequiredVersion}}`,
			map[string]interface{}{
				"Version":         cf.Version,
				"ApiVersion":      r.config.ApiVersion(),
				"CommandName":     r.commandName,
				"RequiredVersion": r.requiredVersion.String(),
			}))
	}

	return true
}
开发者ID:Doebe,项目名称:workplace,代码行数:26,代码来源:min_api_version.go


示例18: Requirements

func (cmd *DeleteRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement {
	if len(fc.Args()) != 1 {
		cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("delete-route"))
	}

	if fc.IsSet("port") && (fc.IsSet("hostname") || fc.IsSet("path")) {
		cmd.ui.Failed(T("Cannot specify port together with hostname and/or path."))
	}

	cmd.domainReq = requirementsFactory.NewDomainRequirement(fc.Args()[0])

	requiredVersion, err := semver.Make("2.36.0")
	if err != nil {
		panic(err.Error())
	}

	var reqs []requirements.Requirement

	if fc.String("path") != "" {
		reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--path'", requiredVersion))
	}

	if fc.IsSet("port") {
		reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--port'", cf.TCPRoutingMinimumAPIVersion))
	}

	reqs = append(reqs, []requirements.Requirement{
		requirementsFactory.NewLoginRequirement(),
		cmd.domainReq,
	}...)

	return reqs
}
开发者ID:Reejoshi,项目名称:cli,代码行数:33,代码来源:delete_route.go


示例19: IsMinApiVersion

func (c *ConfigRepository) IsMinApiVersion(version string) bool {
	var apiVersion string
	c.read(func() {
		apiVersion = c.data.ApiVersion
	})

	requiredVersion, err := semver.Make(version)
	if err != nil {
		return false
	}
	actualVersion, err := semver.Make(apiVersion)
	if err != nil {
		return false
	}
	return actualVersion.GTE(requiredVersion)
}
开发者ID:vframbach,项目名称:cli,代码行数:16,代码来源:config_repository.go


示例20: Requirements

func (cmd *CreateRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
	if len(fc.Args()) != 2 {
		cmd.ui.Failed(T("Incorrect Usage. Requires SPACE and DOMAIN as arguments\n\n") + command_registry.Commands.CommandUsage("create-route"))
	}

	domainName := fc.Args()[1]

	cmd.spaceReq = requirementsFactory.NewSpaceRequirement(fc.Args()[0])
	cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName)

	requiredVersion, err := semver.Make("2.36.0")
	if err != nil {
		panic(err.Error())
	}

	var reqs []requirements.Requirement

	if fc.String("path") != "" {
		reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--path'", requiredVersion))
	}

	reqs = append(reqs, []requirements.Requirement{
		requirementsFactory.NewLoginRequirement(),
		requirementsFactory.NewTargetedOrgRequirement(),
		cmd.spaceReq,
		cmd.domainReq,
	}...)

	return reqs, nil
}
开发者ID:vframbach,项目名称:cli,代码行数:30,代码来源:create_route.go



注:本文中的github.com/blang/semver.Make函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang semver.MustParse函数代码示例发布时间:2022-05-24
下一篇:
Golang frontend.Client类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap