Minimalist Go cross-platform API for locking
LockAPI is a small but useful and efficient Go library dedicated to locking files via OS-specific system calls:
- fcntl on Linux and Mac OS
- LockFileEx and UnlockFileEx in kernel32.dll on Windows
These details are masked by a simplified, cross-platform facade provided by the library.
The installation requires, as usual, go get:
go get github.com/giancosta86/LockAPI/lockapi
LockAPI has been created with Go 1.5.
It has been tested on Windows (8.1) and Linux (Xubuntu 15.10); support for Mac OS (Darwin) has been introduced, but is currently untested.
To test LockAPI on your current system, run:
go test github.com/giancosta86/LockAPI/lockapitest -v
after installing the the library.
First of all, import the library package into a source file:
import "github.com/giancosta86/LockAPI/lockapi"
From now on, you can use the functions available in the lockapi package.
The full GoDoc reference is available at this page.
Simple example programs can be found in the test package: