fslock

package
v0.4.7-dirty Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLocked = errors.New("fslock: directory is locked")

ErrLocked is signaled when someone tries to lock an already locked file.

Functions

This section is empty.

Types

type Locker

type Locker struct {
	// contains filtered or unexported fields
}

Locker is a simple utility meant to create lock files. This is to prevent multiple processes from managing the same working directory by purpose or accident. NOTE: Windows is not supported.

func Lock

func Lock(path string) (*Locker, error)

Lock creates a new Locker under the given 'path' and immediately does Lock on it.

func New

func New(path string) *Locker

New creates a new Locker with a File pointing to the given 'path'.

func (*Locker) Lock

func (l *Locker) Lock() error

Lock locks the file. Subsequent calls will error with ErrLocked on any Locker instance looking to the same path.

func (*Locker) Unlock

func (l *Locker) Unlock() error

Unlock frees up the lock.

Jump to

Keyboard shortcuts

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