tailscale.comtailscale.com/util/dirwalk Index | Files

package dirwalk

import "tailscale.com/util/dirwalk"

Package dirwalk contains code to walk a directory.

Index

Functions

func WalkShallow

func WalkShallow(dirName mem.RO, fn WalkFunc) error

WalkShallow reads the entries in the named directory and calls fn for each. It does not recurse into subdirectories.

If fn returns an error, iteration stops and WalkShallow returns that value.

On Linux, WalkShallow does not allocate, so long as certain methods on the WalkFunc's DirEntry are not called which necessarily allocate.

Types

type WalkFunc

type WalkFunc func(name mem.RO, de fs.DirEntry) error

WalkFunc is the callback type used with WalkShallow.

The name and de are only valid for the duration of func's call and should not be retained.

Source Files

dirwalk.go dirwalk_linux.go

Version
v1.84.1 (latest)
Published
May 29, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
1 day ago

Tools for package owners.