Categorygithub.com/zbiljic/go-filelock
modulepackage
0.0.0-20170914061330-1dbf7103ab7d
Repository: https://github.com/zbiljic/go-filelock.git
Documentation: pkg.go.dev

# README

go-filelock

GoDoc License

Linux
Windows

Package go-filelock provides a cross-process mutex based on file locks that works on windows and *nix platforms.

Installation

go get github.com/zbiljic/go-filelock

Example:

import github.com/zbiljic/go-filelock

fl, err := filelock.New(filename)
if err != nil {
    panic(err)
}
var lock filelock.TryLockerSafe
lock, err = fl.Lock()
if err != nil {
    panic(err)
}
defer lock.Unlock()

...

See the reference for more info.


Copyright © 2017 Nemanja Zbiljić

# Functions

New creates a new lock.

# Constants

This used to call syscall.Flock() but that call fails with EBADF on NFS.
This used to call syscall.Flock() but that call fails with EBADF on NFS.
This used to call syscall.Flock() but that call fails with EBADF on NFS.

# Variables

ErrLocked is returned if the backing file is already locked by some other process.
Various errors returned by this package.

# Interfaces

TryLocker is a sync.Locker augmented with TryLock.
TryLockerSafe is like TryLocker, but the methods can return an error and never panic.