• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

flock-0.7.0/H05-Oct-2018-

.gitignoreH A D06-Oct-2020266

.travis.ymlH A D06-Oct-2020161

LICENSEH A D06-Oct-20201.4 KiB

README.mdH A D06-Oct-20201.2 KiB

appveyor.ymlH A D06-Oct-2020517

flock.goH A D06-Oct-20203.6 KiB

flock_unix.goH A D06-Oct-20205.6 KiB

flock_winapi.goH A D06-Oct-20201.9 KiB

flock_windows.goH A D06-Oct-20204.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