本文整理汇总了Golang中github.com/spf13/cast.ToStringMapString函数的典型用法代码示例。如果您正苦于以下问题:Golang ToStringMapString函数的具体用法?Golang ToStringMapString怎么用?Golang ToStringMapString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ToStringMapString函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: readDepRepos
func (r *Repo) readDepRepos(v *viper.Viper) ([]*Repo, error) {
rdesc := r.rdesc
repos := []*Repo{}
branch, _, ok := rdesc.Match(r)
if !ok {
// No matching branch, barf!
return nil, util.NewNewtError(fmt.Sprintf("No "+
"matching branch for %s repo", r.Name()))
}
repoTag := fmt.Sprintf("%s.repositories", branch)
repoList := v.GetStringMap(repoTag)
for repoName, repoItf := range repoList {
repoVars := cast.ToStringMapString(repoItf)
dl, err := downloader.LoadDownloader(repoName, repoVars)
if err != nil {
return nil, err
}
rversreq := repoVars["vers"]
newRepo, err := NewRepo(repoName, rversreq, dl)
if err != nil {
return nil, err
}
rd, err := NewRepoDependency(repoName, rversreq)
if err != nil {
return nil, err
}
rd.Storerepo = newRepo
r.AddDependency(rd)
repos = append(repos, newRepo)
}
return repos, nil
}
示例2: GetStringMapString
func (v *Viper) GetStringMapString(key string) map[string]string {
return cast.ToStringMapString(v.Get(key))
}
示例3: GetStringMapString
func GetStringMapString(key string) map[string]string {
return cast.ToStringMapString(Get(key))
}
示例4: GetStringMapString
// Returns the value associated with the key as a map of strings
func (c RawConfig) GetStringMapString(key string) map[string]string {
return cast.ToStringMapString(c.Get(key))
}
示例5: GetStringMapString
func (manager *Config) GetStringMapString(key string) map[string]string {
return cast.ToStringMapString(manager.Get(key))
}
示例6: parseFlashArea
func parseFlashArea(
name string, ymlFields map[string]interface{}) (FlashArea, error) {
area := FlashArea{
Name: name,
}
idPresent := false
devicePresent := false
offsetPresent := false
sizePresent := false
var isSystem bool
area.Id, isSystem = SYSTEM_AREA_NAME_ID_MAP[name]
var err error
fields := cast.ToStringMapString(ymlFields)
for k, v := range fields {
switch k {
case "user_id":
if isSystem {
return area, flashAreaErr(name,
"system areas cannot specify a user ID")
}
userId, err := util.AtoiNoOct(v)
if err != nil {
return area, flashAreaErr(name, "invalid user id: %s", v)
}
area.Id = userId + AREA_USER_ID_MIN
idPresent = true
case "device":
area.Device, err = util.AtoiNoOct(v)
if err != nil {
return area, flashAreaErr(name, "invalid device: %s", v)
}
devicePresent = true
case "offset":
area.Offset, err = util.AtoiNoOct(v)
if err != nil {
return area, flashAreaErr(name, "invalid offset: %s", v)
}
offsetPresent = true
case "size":
area.Size, err = parseSize(v)
if err != nil {
return area, flashAreaErr(name, err.Error())
}
sizePresent = true
default:
util.StatusMessage(util.VERBOSITY_QUIET,
"Warning: flash area \"%s\" contains unrecognized field: %s",
name, k)
}
}
if !isSystem && !idPresent {
return area, flashAreaErr(name, "required field \"user_id\" missing")
}
if !devicePresent {
return area, flashAreaErr(name, "required field \"device\" missing")
}
if !offsetPresent {
return area, flashAreaErr(name, "required field \"offset\" missing")
}
if !sizePresent {
return area, flashAreaErr(name, "required field \"size\" missing")
}
return area, nil
}
示例7: GetStringMapString
func (l *Language) GetStringMapString(key string) map[string]string {
return cast.ToStringMapString(l.Get(key))
}
示例8: Load
func Load(basePkg *pkg.LocalPackage) (*MfgImage, error) {
v, err := util.ReadConfig(basePkg.BasePath(),
strings.TrimSuffix(MFG_YAML_FILENAME, ".yml"))
if err != nil {
return nil, err
}
mi := &MfgImage{
basePkg: basePkg,
}
bootName := v.GetString("mfg.bootloader")
if bootName == "" {
return nil, mi.loadError("mfg.bootloader field required")
}
mi.boot, err = mi.loadTarget(bootName)
if err != nil {
return nil, err
}
imgNames := v.GetStringSlice("mfg.images")
if imgNames != nil {
for _, imgName := range imgNames {
imgTarget, err := mi.loadTarget(imgName)
if err != nil {
return nil, err
}
mi.images = append(mi.images, imgTarget)
}
}
if len(mi.images) > 2 {
return nil, mi.loadError("too many images (%d); maximum is 2",
len(mi.images))
}
itf := v.Get("mfg.raw")
slice := cast.ToSlice(itf)
if slice != nil {
for i, entryItf := range slice {
yamlEntry := cast.ToStringMapString(entryItf)
entry, err := mi.loadRawEntry(i, yamlEntry)
if err != nil {
return nil, err
}
mi.rawEntries = append(mi.rawEntries, entry)
}
}
proj := project.GetProject()
bspLpkg, err := proj.ResolvePackage(mi.basePkg.Repo(),
mi.boot.BspName)
if err != nil {
return nil, mi.loadError(
"could not resolve boot loader BSP package: %s",
mi.boot.BspName)
}
mi.bsp, err = pkg.NewBspPackage(bspLpkg)
if err != nil {
return nil, mi.loadError(err.Error())
}
for _, imgTarget := range mi.images {
if len(mi.images) > 1 && imgTarget.LoaderName != "" {
return nil, mi.loadError("only one image allowed in "+
"split image mode (%s is a split build)", imgTarget.Name())
}
if imgTarget.Bsp() != mi.bsp.LocalPackage {
return nil, mi.loadError(
"image target \"%s\" specified conflicting BSP; "+
"boot loader uses %s, image uses %s",
imgTarget.Name(), mi.bsp.Name(), imgTarget.BspName)
}
}
if err := mi.detectInvalidDevices(); err != nil {
return nil, err
}
return mi, nil
}