Updated
On this page
Package filelock provides platform-safe file locking for append operations.
#internal/filelock
#internal/filelock
Package filelock provides platform-safe file locking for append operations. On Unix, uses flock(2) for advisory locking. On Windows, flock is a no-op since the write sizes are small enough for atomic O_APPEND guarantees and scrub policies are serialized by a coordination lock.
#LockedAppend
go
func LockedAppend(path string, data []byte, mkdirAll bool) errorLockedAppend opens path with O_WRONLY|O_APPEND|O_CREATE, acquires an advisory lock, writes data, and releases the lock. If mkdirAll is true, the parent directory is created first.