32 lines
428 B
Go
32 lines
428 B
Go
package utils
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func ExpandGlob(patterns []string) ([]string, error) {
|
|
var result []string
|
|
|
|
for _, p := range patterns {
|
|
matches, err := filepath.Glob(p)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
for _, m := range matches {
|
|
info, err := os.Stat(m)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
|
|
if info.IsDir() {
|
|
continue
|
|
}
|
|
|
|
result = append(result, m)
|
|
}
|
|
}
|
|
|
|
return result, nil
|
|
} |