Exports visit function from base.

This commit is contained in:
James Phillips 2017-02-23 21:01:06 -08:00
parent ec7598f261
commit a48ecf56a9
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
2 changed files with 5 additions and 5 deletions

View File

@ -254,14 +254,14 @@ func float64ToUintValueFunc() mapstructure.DecodeHookFunc {
} }
} }
// visitFn is a callback that gets a chance to visit each file found during a // VisitFn is a callback that gets a chance to visit each file found during a
// traversal with visit(). // traversal with visit().
type visitFn func(path string) error type VisitFn func(path string) error
// visit will call the visitor function on the path if it's a file, or for each // visit will call the visitor function on the path if it's a file, or for each
// file in the path if it's a directory. Directories will not be recursed into, // file in the path if it's a directory. Directories will not be recursed into,
// and files in the directory will be visited in alphabetical order. // and files in the directory will be visited in alphabetical order.
func visit(path string, visitor visitFn) error { func Visit(path string, visitor VisitFn) error {
f, err := os.Open(path) f, err := os.Open(path)
if err != nil { if err != nil {
return fmt.Errorf("error reading %q: %v", path, err) return fmt.Errorf("error reading %q: %v", path, err)

View File

@ -108,10 +108,10 @@ func TestConfigUtil_Visit(t *testing.T) {
} }
basePath := "../../test/command/merge" basePath := "../../test/command/merge"
if err := visit(basePath, visitor); err != nil { if err := Visit(basePath, visitor); err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
if err := visit(path.Join(basePath, "subdir", "c.json"), visitor); err != nil { if err := Visit(path.Join(basePath, "subdir", "c.json"), visitor); err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }