← All projects

darvaza.org/x/fs

Helpers for working with fs.FS — globbing, extended interfaces, and file locking.

Shadow of Go's io/fs package that re-exports standard types and adds write-side interfaces mirroring osChmodFS, ChtimesFS, MkdirFS, MkdirAllFS, MkdirTempFS, ReadlinkFS, RemoveFS, RemoveAllFS, RenameFS, SymlinkFS, and WriteFileFS.

File globbing compiles patterns via gobwas/glob with full ** support for recursive matching. Glob walks an fs.FS and returns all matches; GlobCompile and Match separate compilation from traversal for reuse. Clean and Split extend the standard path utilities with validity reporting.

The fssyscall sub-package provides cross-platform advisory file locking — LockEx, UnlockEx, and non-blocking TryLockEx — backed by flock(2) on Linux and LockFileEx on Windows. Convenience wrappers (FLockEx, FUnlockEx, FTryLockEx) accept an *os.File directly. The flock sub-package wraps these into a single LockEx(filename) call.