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

filelock

package
v1.6.1 Latest Latest
Warning

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

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

Documentation

Overview

Package filelock locks an open file for one process at a time, with the lock of the system: flock on Unix, LockFileEx on Windows. The lock is advisory on both: it keeps no one from reading or writing the file, only from locking it. It stays with the file until it is closed, and with every copy of its descriptor.

Index

Constants

This section is empty.

Variables

View Source
var ErrLocked = errors.New("the file is locked by another process")

ErrLocked is a file another process holds the lock on.

Functions

func Lock

func Lock(file *os.File, wait bool) error

Lock takes the exclusive lock on the file. Unless it waits, it returns ErrLocked while another process holds the lock.

Types

This section is empty.

Jump to

Keyboard shortcuts

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