Source file src/io/fs/example_test.go
1 // Copyright 2021 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package fs_test 6 7 import ( 8 "fmt" 9 "io/fs" 10 "log" 11 "os" 12 ) 13 14 func ExampleWalkDir() { 15 root := "/usr/local/go/bin" 16 fileSystem := os.DirFS(root) 17 18 fs.WalkDir(fileSystem, ".", func(path string, d fs.DirEntry, err error) error { 19 if err != nil { 20 log.Fatal(err) 21 } 22 fmt.Println(path) 23 return nil 24 }) 25 } 26