filelocker

package module
v0.0.0-...-d39278d Latest Latest
Warning

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

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

README

FileLocker GoDoc Status Go Report Card

FileLocker is a file-locking helper library (and CLI utility) for leveraging *nix OS-level file locks.

Features
  • Lock
  • TryLock
  • LockWithContext
  • Unlock

Usage

Documentation

Index

Constants

View Source
const (
	// ErrIsLocked is returned when a file is already locked
	ErrIsLocked = errors.Error("file is already locked")
	// ErrTimeout is returned when a timeout has been exceeded while acquiring a lock
	ErrTimeout = errors.Error("timeout exceeded when acquiring lock")
)

Variables

This section is empty.

Functions

func Lock

func Lock(f *os.File) (err error)

Lock will acquire a *nix file lock on the provided file

func LockWithContext

func LockWithContext(ctx context.Context, f *os.File) error

LockWithContext will acquire a *nix file lock on the provided file with context.Context

func TryLock

func TryLock(f *os.File) (err error)

TryLock will attempt to immediately acquire a *nix file lock on the provided file

func Unlock

func Unlock(f *os.File) (err error)

Unlock will release a *nix file lock on the provided file

Types

This section is empty.

Directories

Path Synopsis
cli
filelocker command

Jump to

Keyboard shortcuts

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