本文整理匯總了Golang中github.com/eris-ltd/eris-cli/Godeps/_workspace/src/github.com/spf13/viper.Viper.Unmarshal方法的典型用法代碼示例。如果您正苦於以下問題:Golang Viper.Unmarshal方法的具體用法?Golang Viper.Unmarshal怎麽用?Golang Viper.Unmarshal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eris-ltd/eris-cli/Godeps/_workspace/src/github.com/spf13/viper.Viper
的用法示例。
在下文中一共展示了Viper.Unmarshal方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: marshalActionDefinition
// marshal from viper to definitions struct
func marshalActionDefinition(actionConf *viper.Viper, action *def.Action) error {
err := actionConf.Unmarshal(action)
if err != nil {
return fmt.Errorf("Tragic! The marmots could not read that action definition file:\n%v\n", err)
}
return nil
}
示例2: marshallGlobalConfig
func marshallGlobalConfig(globalConfig *viper.Viper, config *ErisConfig) error {
err := globalConfig.Unmarshal(config)
if err != nil {
return err
}
return nil
}
示例3: 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
}
示例4: MarshalServiceDefinition
func MarshalServiceDefinition(serviceConf *viper.Viper, srv *definitions.ServiceDefinition) error {
err := serviceConf.Unmarshal(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 ls --known] and retry.\n")
}
// toml bools don't really marshal well
if serviceConf.GetBool("service.data_container") {
srv.Service.AutoData = true
}
return nil
}
示例5: 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
}