lockfile

package
v0.0.0-...-29a3764 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLocked ...
	ErrLocked = errors.New("already locked by another process")
	// ErrAlreadyLocked ...
	ErrAlreadyLocked = errors.New("the lockfile is already locked")
	// ErrAlreadyUnlocked ...
	ErrAlreadyUnlocked = errors.New("already unlocked")
	// ErrInvalidPID ...
	ErrInvalidPID = errors.New("invalid pid")
)

Functions

This section is empty.

Types

type LockFile

type LockFile struct {
	File string
	// contains filtered or unexported fields
}

LockFile ...

func New

func New(file string) (*LockFile, error)

New Creates a new lockfile.

func (*LockFile) Lock

func (lf *LockFile) Lock() (int, error)

Lock attempts to lock the lockfile. If the lockfile was already locked by this process, it returns ErrAlreadyLocked. Otherwise it typically returns ErrLocked if already locked by another process, and nil if not locked.

func (*LockFile) Unlock

func (lf *LockFile) Unlock() error

Unlock LockFile.Unlock unlocks the lockfile. If the lockfile was not locked it returns ErrAlreadyUnlocked. Unlock will delete the lockfile if it is not already unlocked.

Jump to

Keyboard shortcuts

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