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

fslock

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Overview

Package fslock provides advisory file locking for coordinating exclusive access to shared resources across processes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

Lock represents an acquired advisory file lock.

func Acquire

func Acquire(path string, timeout time.Duration) (Lock, error)

Acquire acquires an exclusive advisory lock on the file at path, retrying until timeout elapses. Returns an error if the lock cannot be acquired.

func (Lock) Release

func (l Lock) Release() error

Release unlinks the lock file and releases the lock. Unlinking before closing ensures no new caller can open the same inode and take the lock while we still hold it; combined with the inode recheck in Acquire, this guarantees that a fresh file at the same path is never raced against a soon-to-be-deleted one.

Jump to

Keyboard shortcuts

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