package
0.0.0-20240819164739-f47aed85de5a
Repository: https://github.com/unix-world/smartgo.git
Documentation: pkg.go.dev

# README

Go file locking

Overview

Exclusive file locks with timeouts using flock.

Example

  // Try to obtain an exclusive file lock with a timeout
  lock := filelock.FileLock{Path: "example.lock", Timeout: time.Second * 1}
  err := lock.Lock()
  if err != nil {
    if err == ErrLockTimeout {
      // Lock timeout
    }

    // Other error
  }

  // Lock obtained successfully, must be released.
  defer lock.Unlock()

See tests for more examples.

License

Apache 2.0

# Variables

No description provided by the author
No description provided by the author

# Structs

No description provided by the author