當前位置: 首頁>>代碼示例>>Golang>>正文


Golang viper.Viper類代碼示例

本文整理匯總了Golang中github.com/eris-ltd/eris-cli/Godeps/_workspace/src/github.com/spf13/viper.Viper的典型用法代碼示例。如果您正苦於以下問題:Golang Viper類的具體用法?Golang Viper怎麽用?Golang Viper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Viper類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: marshalActionDefinition

// marshal from viper to definitions struct
func marshalActionDefinition(actionConf *viper.Viper, action *def.Action) error {
	err := actionConf.Marshal(action)
	if err != nil {
		return fmt.Errorf("Tragic! The marmots could not read that action definition file:\n%v\n", err)
	}
	return nil
}
開發者ID:alexandrev,項目名稱:eris-cli,代碼行數:8,代碼來源:load.go

示例2: MarshalChainDefinition

// marshal from viper to definitions struct
func MarshalChainDefinition(chainConf *viper.Viper, chain *definitions.Chain) error {
	chnTemp := definitions.BlankChain()
	// logger.Debugf("Loader.Chain: ChainID =>\t\t%v\n", chain.ChainID)
	// logger.Debugf("Loader.Chain. Conf =>\t\t%v\n", chainConf)
	err := chainConf.Marshal(chnTemp)
	if err != nil {
		return fmt.Errorf("The marmots coult not marshal from viper to chain def: %v", err)
	}
	// logger.Debugf("Loader.Chain.Marshal: ChanID =>\t%v\n", chnTemp.ChainID)

	mergeChainAndService(chain, chnTemp.Service)
	chain.ChainID = chnTemp.ChainID

	// toml bools don't really marshal well
	// data_container can be in the chain or
	// in the service layer. this is very
	// opinionated. we know.
	for _, s := range []string{"", "service."} {
		if chainConf.GetBool(s + "data_container") {
			logger.Debugln("Loader.Chain.Marshal: Data Containers Turned On.")
			chain.Service.AutoData = true
		}
	}

	return nil
}
開發者ID:slowtokyo,項目名稱:eris-cli,代碼行數:27,代碼來源:chains.go

示例3: marshallGlobalConfig

func marshallGlobalConfig(globalConfig *viper.Viper, config *ErisConfig) error {
	err := globalConfig.Marshal(config)
	if err != nil {
		return err
	}

	return nil
}
開發者ID:alexandrev,項目名稱:eris-cli,代碼行數:8,代碼來源:config.go

示例4: marshalContractPackage

func marshalContractPackage(contConf *viper.Viper) (*definitions.Contracts, error) {
	pkg := definitions.BlankPackage()
	err := contConf.Unmarshal(pkg)
	app := pkg.Contracts
	app.Name = pkg.Name

	if err != nil {
		// Viper's error messages are atrocious.
		return nil, fmt.Errorf("Sorry, the marmots could not figure that package.json out.\nPlease check your package.json is properly formatted.\n")
	}

	return app, nil
}
開發者ID:antonylewis,項目名稱:eris-cli,代碼行數:13,代碼來源:contracts.go

示例5: MarshalServiceDefinition

func MarshalServiceDefinition(serviceConf *viper.Viper, srv *definitions.ServiceDefinition) error {
	err := serviceConf.Marshal(srv)
	if err != nil {
		// Vipers error messages are atrocious.
		return fmt.Errorf("Sorry, the marmots could not figure that service definition out.\nPlease check for known services with [eris services known] and retry.\n")
	}

	// toml bools don't really marshal well
	if serviceConf.GetBool("service.data_container") {
		srv.Service.AutoData = true
	}

	return nil
}
開發者ID:alexandrev,項目名稱:eris-cli,代碼行數:14,代碼來源:services.go

示例6: marshalContractPackage

func marshalContractPackage(contConf *viper.Viper) (*definitions.Contracts, error) {
	pkg := definitions.BlankPackage()
	err := contConf.Marshal(pkg)
	dapp := pkg.Contracts
	dapp.Name = pkg.Name

	logger.Debugf("Package marshalled, testType =>\t%s\n", dapp.TestType)
	logger.Debugf("\tdeployType =>\t\t%s\n", dapp.DeployType)
	logger.Debugf("\ttestTask =>\t\t%s\n", dapp.TestTask)
	logger.Debugf("\tdeployTask =>\t\t%s\n", dapp.DeployTask)

	if err != nil {
		// Viper's error messages are atrocious.
		return nil, fmt.Errorf("Sorry, the marmots could not figure that package.json out.\nPlease check your package.json is properly formatted.\n")
	}

	return dapp, nil
}
開發者ID:slowtokyo,項目名稱:eris-cli,代碼行數:18,代碼來源:contracts.go

示例7: MarshalChainDefinition

// marshal from viper to definitions struct
func MarshalChainDefinition(chainConf *viper.Viper, chain *definitions.Chain) error {
	log.Debug("Marshalling chain")
	chnTemp := definitions.BlankChain()
	err := chainConf.Unmarshal(chnTemp)
	if err != nil {
		return fmt.Errorf("The marmots coult not marshal from viper to chain def: %v", err)
	}

	util.Merge(chain.Service, chnTemp.Service)
	chain.ChainID = chnTemp.ChainID

	// toml bools don't really marshal well
	// data_container can be in the chain or
	// in the service layer. this is very
	// opinionated. we know.
	for _, s := range []string{"", "service."} {
		if chainConf.GetBool(s + "data_container") {
			chain.Service.AutoData = true
			log.WithField("autodata", chain.Service.AutoData).Debug()
		}
	}

	return nil
}
開發者ID:antonylewis,項目名稱:eris-cli,代碼行數:25,代碼來源:chains.go

示例8: Edit

func Edit(conf *viper.Viper, configVals []string) error {
	filePath := conf.ConfigFileUsed()
	if len(configVals) == 0 {
		if err := Editor(filePath); err != nil {
			return err
		}
	} else {
		for _, v := range configVals {
			spl := strings.Split(v, "=")
			if len(spl) != 2 {
				return fmt.Errorf("config values must be specified as <key>=<value>")
			}
			key, val := spl[0], spl[1]
			spl = strings.Split(val, ",")
			if len(spl) > 1 {
				conf.Set(key, spl)
			} else {
				conf.Set(key, val)
			}
		}
	}

	return nil
}
開發者ID:alexandrev,項目名稱:eris-cli,代碼行數:24,代碼來源:edit.go


注:本文中的github.com/eris-ltd/eris-cli/Godeps/_workspace/src/github.com/spf13/viper.Viper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。