项目作者: gofrs

项目描述 :
Thread-safe file locking library in Go (originally github.com/theckman/go-flock)
高级语言: Go
项目地址: git://github.com/gofrs/flock.git
创建时间: 2015-08-30T21:45:35Z
项目社区:https://github.com/gofrs/flock

开源协议:BSD 3-Clause "New" or "Revised" License

下载


flock

Go Reference
License
Go Report Card

flock implements a thread-safe file lock.

It also includes a non-blocking TryLock() function to allow locking without blocking execution.

Installation

  1. go get -u github.com/gofrs/flock

Usage

  1. import "github.com/gofrs/flock"
  2. fileLock := flock.New("/var/lock/go-lock.lock")
  3. locked, err := fileLock.TryLock()
  4. if err != nil {
  5. // handle locking error
  6. }
  7. if locked {
  8. // do work
  9. fileLock.Unlock()
  10. }

For more detailed usage information take a look at the package API docs on
GoDoc.

License

flock is released under the BSD 3-Clause License. See the LICENSE file for more details.

Project History

This project was originally github.com/theckman/go-flock, it was transferred to Gofrs by the original author Tim Heckman .