1
0
Fork 0
mirror of https://github.com/vbatts/sl-feeds.git synced 2024-11-25 17:05:39 +00:00
sl-feeds/util/find.go
Vincent Batts c5585b2c1d
*: golint
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-01-29 15:54:47 -05:00

25 lines
484 B
Go

package util
import (
"os"
"path/filepath"
)
// FindFiles is a convenience for walk a directory tree for a particular file
// name.
func FindFiles(root, name string) (paths []string, err error) {
paths = []string{}
err = filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if filepath.Base(path) == name {
paths = append(paths, path)
}
return nil
})
if err != nil {
return nil, err
}
return paths, nil
}