filelock

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package filelock takes an open file's exclusive lock, across processes. The system releases a lock when its process ends, so a crash never leaves one held.

Index

Constants

This section is empty.

Variables

View Source
var ErrHeld = errors.New("the lock is held")

ErrHeld is a lock another process, or another open of the file, holds.

Functions

func Lock

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

Lock takes f's lock, waiting while it's held, until ctx is done. An error other than the lock being held, such as a file system without locks, returns at once.

func TryLock

func TryLock(f *os.File) error

TryLock takes f's lock without waiting: ErrHeld when it's held.

func Unlock

func Unlock(f *os.File)

Unlock releases f's lock.

Types

This section is empty.

Jump to

Keyboard shortcuts

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