On this page
flock(2)-guarded appends, which is what makes a concurrent append atomic. There is no Windows implementation on purpose: a Windows build fails to compile.
#internal/filelock
#internal/filelock
Package filelock provides file locking for append operations, using flock(2) for advisory locking. There is no Windows implementation on purpose: the appended files have no line-size limit, so the lock -- not POSIX O_APPEND atomicity -- is the only thing that keeps concurrent appends intact, and a no-op lock would silently mean no integrity at all. A Windows build fails to compile here; see todo/.defer/windows-lockfileex-support.md.
#LockedAppend
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.