-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: tune examples for unix and windows
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
- Loading branch information
1 parent
39ac328
commit ecfb568
Showing
3 changed files
with
66 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//go:build !windows && !plan9 | ||
|
||
package locafero | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/afero" | ||
) | ||
|
||
func ExampleFinder_Find() { | ||
fsys := afero.NewBasePathFs(afero.NewOsFs(), "testdata") | ||
|
||
finder := Finder{ | ||
Paths: []string{ | ||
"/home/user", | ||
"/etc", | ||
}, | ||
Names: []string{"config.*"}, | ||
Type: FileTypeFile, | ||
} | ||
|
||
results, err := finder.Find(fsys) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Println("On Unix:", results) | ||
|
||
// Output: | ||
// On Unix: [/home/user/config.yaml /etc/config.yaml] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//go:build windows | ||
|
||
package locafero | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/afero" | ||
) | ||
|
||
func ExampleFinder_Find() { | ||
// Use relative paths for Windows, because we do not know the absolute path. | ||
// fsys := afero.NewBasePathFs(afero.NewOsFs(), "testdata") | ||
fsys := afero.NewOsFs() | ||
|
||
finder := Finder{ | ||
Paths: []string{ | ||
"testdata\\home\\user", | ||
"testdata\\etc", | ||
}, | ||
Names: []string{"config.*"}, | ||
Type: FileTypeFile, | ||
} | ||
|
||
results, err := finder.Find(fsys) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Println("On Windows:", results) | ||
|
||
// Output: | ||
// On Windows: [testdata\home\user\config.yaml testdata\etc\config.yaml] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters