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


Golang cast.ToStringMapString函数代码示例

本文整理汇总了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
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:40,代码来源:repo.go

示例2: GetStringMapString

func (v *Viper) GetStringMapString(key string) map[string]string {
	return cast.ToStringMapString(v.Get(key))
}
开发者ID:pandemicsyn,项目名称:stalker,代码行数:3,代码来源:viper.go

示例3: GetStringMapString

func GetStringMapString(key string) map[string]string {
	return cast.ToStringMapString(Get(key))
}
开发者ID:jordie,项目名称:viper,代码行数:3,代码来源:viper.go

示例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))
}
开发者ID:mefellows,项目名称:parity,代码行数:4,代码来源:config.go

示例5: GetStringMapString

func (manager *Config) GetStringMapString(key string) map[string]string {
	return cast.ToStringMapString(manager.Get(key))
}
开发者ID:MightyE,项目名称:confer,代码行数:3,代码来源:confer.go

示例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
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:75,代码来源:flash.go

示例7: GetStringMapString

func (l *Language) GetStringMapString(key string) map[string]string {
	return cast.ToStringMapString(l.Get(key))
}
开发者ID:tarsisazevedo,项目名称:hugo,代码行数:3,代码来源:language.go

示例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
}
开发者ID:apache,项目名称:incubator-mynewt-newt,代码行数:85,代码来源:load.go


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