Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tekintian/gflock

go语言实现的一个高效,轻量级的文件锁
https://github.com/tekintian/gflock

Last synced: about 9 hours ago
JSON representation

go语言实现的一个高效,轻量级的文件锁

Awesome Lists containing this project

README

        

# go file lock

Go 语言里面用的文件锁 gflock, 来源于 gofrs/flock,做了一系列升级改造和 Bug 修复!

`gflock` implements a thread-safe sync.Locker interface for file locking. It also
includes a non-blocking TryLock() function to allow locking without blocking execution.

## Installation

```
go get -u github.com/tekitian/gflock
```

## Usage

```Go
import "github.com/tekitian/gflock"

fileLock := gflock.New("/var/lock/go-lock.lock")

locked, err := fileLock.TryLock()

if err != nil {
// handle locking error
}

if locked {
// do work
fileLock.Unlock()
}
```

## thanks for

https://github.com/gofrs/flock