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


Golang Config.GetListDefault方法代碼示例

本文整理匯總了Golang中github.com/ernestokarim/cb/config.Config.GetListDefault方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.GetListDefault方法的具體用法?Golang Config.GetListDefault怎麽用?Golang Config.GetListDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ernestokarim/cb/config.Config的用法示例。


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

示例1: cacherev

func cacherev(c *config.Config, q *registry.Queue) error {
	dirs := c.GetListRequired("cacherev.dirs")
	exclude := c.GetListRequired("cacherev.exclude")
	for _, dir := range dirs {
		dir = filepath.Join("temp", dir)
		if err := filepath.Walk(dir, changeName(exclude)); err != nil {
			return fmt.Errorf("change names walk failed (%s): %s", dir, err)
		}
	}

	rev := c.GetListDefault("cacherev.rev")
	for _, dir := range rev {
		dir = filepath.Join("temp", dir)
		if err := filepath.Walk(dir, changeReferences); err != nil {
			return fmt.Errorf("change references walk failed (%s): %s", dir, err)
		}
	}

	utils.SaveChanges(changes)
	return nil
}
開發者ID:ernestoalejo,項目名稱:cb,代碼行數:21,代碼來源:cacherev.go

示例2: organizeResult

func organizeResult(c *config.Config) error {
	excludes := c.GetListDefault("deploy.exclude")
	includes := c.GetListDefault("deploy.include")
	moves := c.GetListDefault("deploy.moves")

	// Extract list of paths to remove
	removePaths := map[string]bool{}
	walkFn := func(path string, info os.FileInfo) error {
		removePaths[path] = true
		if *config.Verbose {
			log.Printf("flag to remove `%s`...\n", path)
		}
		return nil
	}
	for _, exclude := range excludes {
		exclude = filepath.Join("..", "deploy", exclude)
		if err := utils.NewWalker(exclude).Walk(walkFn); err != nil {
			fmt.Errorf("deploy exclude walker failed: %s", err)
		}
	}

	// Cancel removing of files that are included again
	walkFn = func(path string, info os.FileInfo) error {
		cur := path
		for cur != "." {
			removePaths[cur] = false
			cur = filepath.Dir(cur)
		}
		if *config.Verbose {
			log.Printf("include `%s`...\n", path)
		}
		return nil
	}
	for _, include := range includes {
		include = filepath.Join("..", "deploy", include)
		if err := utils.NewWalker(include).Walk(walkFn); err != nil {
			fmt.Errorf("deploy include walker failed: %s", err)
		}
	}

	// Remove flagged files & folders
	for path, remove := range removePaths {
		if remove {
			if *config.Verbose {
				log.Printf("removing `%s`...\n", path)
			}
			if err := os.RemoveAll(path); err != nil {
				return fmt.Errorf("cannot remove deploy entry: %s", err)
			}
		}
	}

	// Execute move operations
	for _, move := range moves {
		parts := strings.Split(move, "->")
		origin := filepath.Join("..", "deploy", strings.TrimSpace(parts[0]))
		dest := filepath.Join("..", "deploy", strings.TrimSpace(parts[1]))

		if err := os.MkdirAll(filepath.Dir(dest), 0755); err != nil {
			return fmt.Errorf("cannot create dest tree structure: %s", err)
		}

		output, err := utils.Exec("cp", []string{"-r", origin, dest})
		if err != nil {
			fmt.Println(output)
			return fmt.Errorf("copy error: %s", err)
		}
	}

	return nil
}
開發者ID:ernestoalejo,項目名稱:cb,代碼行數:71,代碼來源:deploy.go


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