当前位置: 首页>>代码示例>>Golang>>正文


Golang Contracts.Name方法代码示例

本文整理汇总了Golang中github.com/eris-ltd/eris-cli/definitions.Contracts.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang Contracts.Name方法的具体用法?Golang Contracts.Name怎么用?Golang Contracts.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/eris-ltd/eris-cli/definitions.Contracts的用法示例。


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

示例1: checkAppAndChain

func checkAppAndChain(app *definitions.Contracts, name string) error {
	var chain string

	// name is pulled in from the do struct. need to work with both
	// it (as an override) and the app.ChainName
	switch name {
	case "":
		if app.ChainName == "" {
			return nil
		} else {
			chain = app.ChainName
		}
	case "t", "tmp", "temp":
		return nil
	default:
		chain = name
	}

	if strings.Contains(app.Name, " ") {
		app.Name = strings.Replace(app.Name, " ", "_", -1)
	}

	// this is hacky.... at best.
	if len(app.AppType.ChainTypes) == 1 && app.AppType.ChainTypes[0] == "eth" {
		if r := regexp.MustCompile("eth"); r.MatchString(chain) {
			return nil
		} else {
			return fmt.Errorf("The marmots detected a disturbance in the force.\n\nYou asked them to run the App Type: (%s).\nBut the chainName (%s) doesn't contain the name (%s).\nPlease rename the chain or service to contain the name (%s)", app.AppType.Name, chain, "eth", "eth")
		}
	}

	return nil
}
开发者ID:antonylewis,项目名称:eris-cli,代码行数:33,代码来源:contracts.go


注:本文中的github.com/eris-ltd/eris-cli/definitions.Contracts.Name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。