Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
flock-0.7.0/ | H | 05-Oct-2018 | - | |||
.gitignore | H A D | 06-Oct-2020 | 266 | |||
.travis.yml | H A D | 06-Oct-2020 | 161 | |||
LICENSE | H A D | 06-Oct-2020 | 1.4 KiB | |||
README.md | H A D | 06-Oct-2020 | 1.2 KiB | |||
appveyor.yml | H A D | 06-Oct-2020 | 517 | |||
flock.go | H A D | 06-Oct-2020 | 3.6 KiB | |||
flock_unix.go | H A D | 06-Oct-2020 | 5.6 KiB | |||
flock_winapi.go | H A D | 06-Oct-2020 | 1.9 KiB | |||
flock_windows.go | H A D | 06-Oct-2020 | 4.2 KiB |
README.md
1# flock 2[![TravisCI Build Status](https://img.shields.io/travis/gofrs/flock/master.svg?style=flat)](https://travis-ci.org/gofrs/flock) 3[![GoDoc](https://img.shields.io/badge/godoc-go--flock-blue.svg?style=flat)](https://godoc.org/github.com/gofrs/flock) 4[![License](https://img.shields.io/badge/license-BSD_3--Clause-brightgreen.svg?style=flat)](https://github.com/gofrs/flock/blob/master/LICENSE) 5 6`flock` implements a thread-safe sync.Locker interface for file locking. It also 7includes a non-blocking TryLock() function to allow locking without blocking execution. 8 9## License 10`flock` is released under the BSD 3-Clause License. See the `LICENSE` file for more details. 11 12## Go Compatibility 13This package makes use of the `context` package that was introduced in Go 1.7. As such, this 14package has an implicit dependency on Go 1.7+. 15 16## Installation 17``` 18go get -u github.com/gofrs/flock 19``` 20 21## Usage 22```Go 23import "github.com/gofrs/flock" 24 25fileLock := flock.New("/var/lock/go-lock.lock") 26 27locked, err := fileLock.TryLock() 28 29if err != nil { 30 // handle locking error 31} 32 33if locked { 34 // do work 35 fileLock.Unlock() 36} 37``` 38 39For more detailed usage information take a look at the package API docs on 40[GoDoc](https://godoc.org/github.com/gofrs/flock). 41