Documentation
¶
Overview ¶
Package aferobilly adapts a go-billy/v5 Filesystem to an afero.Fs, so code written against afero can operate on a billy filesystem unchanged.
The common case is a go-git worktree — go-git hands you a billy filesystem, while most Go application code is written against afero — but the adapter imports no VCS package and works for any billy implementation (memfs, osfs, chroot).
Safety: every Fs and File operation is serialised through a configurable sync.Locker (default: a no-op). Pass WithLocker the same mutex that guards whatever produces the filesystem — a repository handle, a pool, a cache — and a live afero.Fs becomes genuinely safe for concurrent use: each operation re-locks, so the handle can never touch the underlying filesystem unsynchronised.
The returned afero.Fs and its Files deliberately expose no accessor for the wrapped billy object, so the lock boundary cannot be bypassed.
The corresponding footgun: a handle (and any file opened from it) must NOT be used inside a critical section that already holds the same locker. Standard Go mutexes are not reentrant, so that self-deadlocks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*billyFs)
Option configures the adapter.
func WithLocker ¶
WithLocker serialises every Fs and File operation through l. Pass the mutex that guards the filesystem's producer (e.g. a ThreadSafeRepo's mutex) to make a live handle concurrency-safe. A nil locker is ignored (the no-op default is kept).