Help us shape the future of Go! Take the 2026 Go Developer Survey

flock

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package flock takes an exclusive advisory lock on a file, shared between processes of the same user.

Index

Constants

This section is empty.

Variables

View Source
var ErrLocked = errors.New("file is locked")

ErrLocked is returned by Lock with wait false when another holder has the lock.

Functions

func Lock

func Lock(ctx context.Context, path string, wait bool) (unlock func() error, err error)

Lock opens or creates path and takes an exclusive lock on it. With wait it retries until the lock frees or ctx ends; without wait it returns ErrLocked at once. The lock ends when unlock runs or the process exits.

Types

This section is empty.

Jump to

Keyboard shortcuts

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