Categorygithub.com/opencoff/go-walk
modulepackage
0.6.5
Repository: https://github.com/opencoff/go-walk.git
Documentation: pkg.go.dev

# README

GoDoc

What is this

This is a concurrent directory traversal library. It returns each entry via a channel or via a caller supplied function (ie callback). In either case, the caller can specify what entries are interesting:

  • Files
  • Directories
  • Special files (symlinks, device nodes etc.)
  • All of the above

It can optionally follow symlinks and detect mount-point crossings.

How can I use it?

Here is an example program:


    dirs := []string{"/etc", "/usr", "/bin", "/sbin", "/lib"}
    opt := walk.Options{
            OneFS: true,
            FollowSymlinks: true,
    }

    ch, errch := walk.Walk(dirs, walk.FILE, &opt)

    go func() {
        for err := range errch {
            fmt.Printf("walk: %s\n", err)
        }
    }()

    // harvest results
    for r := range ch {
        fmt.Printf("%s: %d bytes\n", r.Path, r.Stat.Size())
    }

Who's using this?

go-progs is a collection of go tools including a simpler implementation of du(1).

Licensing Terms

The tool and code is licensed under the terms of the GNU Public License v2.0 (strictly v2.0). If you need a commercial license or a different license, please get in touch with me.

See the file LICENSE for the full terms of the license.

# Functions

DelXattr deletes the extended attributes in 'x' from file 'fn'.
NewXattr returns the extended attributes of file 'fn'.
SetXattr sets the extended attributes of file 'fn' with the data in 'x'.
Walk traverses the entries in 'names' in a concurrent fashion and returns results in a channel of Result.
WalkFunc traverses the entries in 'names' in a concurrent fashion and calls 'apply' for entries that match criteria in 'opt'.

# Constants

This is a short cut for "give me all entries".
device special file (blk and char).
directory.
regular file.
other special files.
symbolic link.

# Structs

Options control the behavior of the filesystem walk.
Result is the data returned as part of the directory walk.

# Type aliases

Type describes the type of a given file system entry.
No description provided by the author