Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tekintian/gflock
go语言实现的一个高效,轻量级的文件锁
https://github.com/tekintian/gflock
Last synced: about 9 hours ago
JSON representation
go语言实现的一个高效,轻量级的文件锁
- Host: GitHub
- URL: https://github.com/tekintian/gflock
- Owner: tekintian
- Created: 2024-05-28T02:49:48.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-05-28T02:52:37.000Z (5 months ago)
- Last Synced: 2024-05-29T18:49:35.147Z (5 months ago)
- Language: Go
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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