Thread-safe file locking for Go
open sourceBSD-3-Clausefree
flock is a Go package that implements a thread-safe file lock, with a non-blocking TryLock() so code can try to take the lock without waiting. It was first theckman/go-flock, which its author moved to the Gofrs organization.
Problems it solves
- stop two copies of my Go program running the same job at once
- take a lock file without blocking if another process holds it
- coordinate access to a shared file between Go processes
Features
- thread-safe file lock
- non-blocking TryLock
- Unlock to release
