Version: v0.3.10 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 4 Imported by: 0




This section is empty.


View Source
var (
	ErrAlreadyLocked = errors.New("Double lock: already own the lock")
	ErrLockFailed    = errors.New("Could not acquire lock")
	ErrLockNotHeld   = errors.New("Could not unlock, lock is not held")

	ErrInodeChangedAtPath = errors.New("Inode changed at path")


This section is empty.


type Flock

type Flock struct {
	// contains filtered or unexported fields

func New

func New(path string) *Flock

New returns a new instance of *Flock. The only parameter it takes is the path to the desired lockfile.

func (*Flock) Lock

func (f *Flock) Lock() error

Lock will acquire the lock. This function may block indefinitely if some other process holds the lock. For a non-blocking version, see Flock.TryLock().

func (*Flock) Path

func (f *Flock) Path() string

Path returns the file path linked to this lock.

func (*Flock) TryLock

func (f *Flock) TryLock() (bool, error)

TryLock will try to acquire the lock, and returns immediately if the lock is already owned by another process.

func (*Flock) Unlock

func (f *Flock) Unlock() error

Unlock removes the lock file from disk and releases the lock. Whatever the result of `.Unlock()`, the caller must assume that it does not hold the lock anymore.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL