flock

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAcquireLock = errors.New("could not acquire lock")
)

Functions

This section is empty.

Types

type FileLocker

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

FileLocker is the structure that wraps exclusive file locking functionality.

func NewLocker

func NewLocker(filepath string) (*FileLocker, error)

NewLocker creates new locker instance for a file path.

func (*FileLocker) Acquire

func (l *FileLocker) Acquire(timeout time.Duration) error

Acquire tries to lock the file for writing (exclusive lock) using flock(2). If the function cannot obtain a lock during the timeout it will return an error.

func (*FileLocker) Release

func (l *FileLocker) Release()

Release releases the lock on the file.

Jump to

Keyboard shortcuts

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