1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00

refactor: simplify for

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2020-11-09 19:16:06 -03:00
parent 9935b87100
commit c125fe3166

View File

@ -14,23 +14,24 @@ import (
func Find(files []config.ExtraFile) (map[string]string, error) {
var result = map[string]string{}
for _, extra := range files {
if extra.Glob != "" {
files, err := zglob.Glob(extra.Glob)
if err != nil {
return result, fmt.Errorf("globbing failed for pattern %s: %w", extra.Glob, err)
if extra.Glob == "" {
continue
}
files, err := zglob.Glob(extra.Glob)
if err != nil {
return result, fmt.Errorf("globbing failed for pattern %s: %w", extra.Glob, err)
}
for _, file := range files {
info, err := os.Stat(file)
if err == nil && info.IsDir() {
log.Debugf("ignoring directory %s", file)
continue
}
for _, file := range files {
info, err := os.Stat(file)
if err == nil && info.IsDir() {
log.Debugf("ignoring directory %s", file)
continue
}
var name = filepath.Base(file)
if old, ok := result[name]; ok {
log.Warnf("overriding %s with %s for name %s", old, file, name)
}
result[name] = file
var name = filepath.Base(file)
if old, ok := result[name]; ok {
log.Warnf("overriding %s with %s for name %s", old, file, name)
}
result[name] = file
}
}
return result, nil