tools: golang.org/x/tools/internal/fastwalk Index | Files

package fastwalk

import "golang.org/x/tools/internal/fastwalk"

Package fastwalk provides a faster version of filepath.Walk for file system scanning tools.

Index

Package Files

fastwalk.go fastwalk_dirent_ino.go fastwalk_dirent_namlen_linux.go fastwalk_unix.go

Variables

var SkipFiles = errors.New("fastwalk: skip remaining files in directory")

SkipFiles is a used as a return value from WalkFuncs to indicate that the callback should not be called for any other files in the current directory. Child directories will still be traversed.

var TraverseLink = errors.New("fastwalk: traverse symlink, assuming target is a directory")

TraverseLink is used as a return value from WalkFuncs to indicate that the symlink named in the call may be traversed.

func Walk Uses

func Walk(root string, walkFn func(path string, typ os.FileMode) error) error

Walk is a faster implementation of filepath.Walk.

filepath.Walk's design necessarily calls os.Lstat on each file, even if the caller needs less info. Many tools need only the type of each file. On some platforms, this information is provided directly by the readdir system call, avoiding the need to stat each file individually. fastwalk_unix.go contains a fork of the syscall routines.

See golang.org/issue/16399

Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root.

If fastWalk returns filepath.SkipDir, the directory is skipped.

Unlike filepath.Walk:

* file stat calls must be done by the user.
  The only provided metadata is the file type, which does not include
  any permission bits.
* multiple goroutines stat the filesystem concurrently. The provided
  walkFn must be safe for concurrent use.
* fastWalk can follow symlinks if walkFn returns the TraverseLink
  sentinel error. It is the walkFn's responsibility to prevent
  fastWalk from going into symlink cycles.

Package fastwalk imports 9 packages (graph) and is imported by 2 packages. Updated 2019-07-15. Refresh now. Tools for package owners.