本文整理匯總了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
}
示例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
}