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

filelock

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package filelock takes an advisory lock on an open file, which the system lets go when the file is closed, whether by the process or by its end, so no lock outlives its holder. It is the platform glue alone, in a package of its own, so the code that waits on a lock is measured where it lives.

Index

Constants

This section is empty.

Variables

View Source
var ErrHeld = errors.New("another open file holds the lock")

ErrHeld reports a lock another open file holds. It is declared beside each platform's TryLock, since a file of build-tagged twins must stand alone for the condition coverage report to read it.

Functions

func TryLock

func TryLock(file *os.File) error

TryLock takes an exclusive lock on file without waiting, and fails with ErrHeld while another open file holds one.

Types

This section is empty.

Jump to

Keyboard shortcuts

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