mirror of https://github.com/status-im/consul.git
Exports visit function from base.
This commit is contained in:
parent
ec7598f261
commit
a48ecf56a9
|
@ -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().
|
||||
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
|
||||
// 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.
|
||||
func visit(path string, visitor visitFn) error {
|
||||
func Visit(path string, visitor VisitFn) error {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading %q: %v", path, err)
|
||||
|
|
|
@ -108,10 +108,10 @@ func TestConfigUtil_Visit(t *testing.T) {
|
|||
}
|
||||
|
||||
basePath := "../../test/command/merge"
|
||||
if err := visit(basePath, visitor); err != nil {
|
||||
if err := Visit(basePath, visitor); err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue