You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bonzai/util/files_test.go

51 lines
833 B
Go

package util_test
import (
"fmt"
"os"
"github.com/rwxrob/bonzai/loop"
"github.com/rwxrob/bonzai/util"
)
func ExampleFiles() {
loop.Println(util.Files("testdata/files"))
// Output:
// testdata/files/bar
// testdata/files/blah
// testdata/files/dir1/
// testdata/files/dir2/
// testdata/files/dir3/
// testdata/files/foo
// testdata/files/other
// testdata/files/some
}
func ExampleFiles_empty() {
os.Chdir("testdata/files")
defer os.Chdir("../..")
loop.Println(util.Files(""))
// Output:
// ./bar
// ./blah
// ./dir1/
// ./dir2/
// ./dir3/
// ./foo
// ./other
// ./some
}
func ExampleFilesWith() {
loop.Println(util.FilesWith("testdata/files", "b"))
// Output:
// testdata/files/bar
// testdata/files/blah
}
func ExampleFiles_not_Directory() {
fmt.Println(util.Files("none"))
// Output:
// []
}