fsutil

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WatchDir added in v0.12.0

func WatchDir(ctx context.Context, dir string, onRetry func(err error)) (*fsnotify.Watcher, error)

WatchDir returns an fsnotify watcher on dir. On macOS and the BSDs, fsnotify lists dir and then inspects every file in it while it adds the watch, so a file removed in between fails the add with fs.ErrNotExist. WatchDir then closes that watcher, calls onRetry with the error when onRetry is not nil, and sets the watch up again on a new watcher every watchRetryInterval. It returns the error of the last attempt after watchAttempts, and ctx.Err() when ctx is done first. Any other error, and fs.ErrNotExist when dir itself is gone, is returned as it is.

func WriteFileAtomic

func WriteFileAtomic(dir, name string, data []byte, perm os.FileMode) error

WriteFileAtomic writes data to dir/name atomically using a temp file and rename. This ensures readers never observe a partially-written file. Both the file contents and the rename are fsynced, so the write survives a host power loss and not merely a process crash.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL