Socket
Socket
Sign inDemoInstall

github.com/gofrs/flock

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/gofrs/flock

Package flock implements a thread-safe interface for file locking. It also includes a non-blocking TryLock() function to allow locking without blocking execution. Package flock is released under the BSD 3-Clause License. See the LICENSE file for more details. While using this library, remember that the locking behaviors are not guaranteed to be the same on each platform. For example, some UNIX-like operating systems will transparently convert a shared lock to an exclusive lock. If you Unlock() the flock from a location where you believe that you have the shared lock, you may accidentally drop the exclusive lock.


Version published

Readme

Source

flock

TravisCI Build Status GoDoc License Go Report Card

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

License

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

Go Compatibility

This package makes use of the context package that was introduced in Go 1.7. As such, this package has an implicit dependency on Go 1.7+.

Installation

go get -u github.com/gofrs/flock

Usage

import "github.com/gofrs/flock"

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

locked, err := fileLock.TryLock()

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

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

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

FAQs

Last updated on 26 Jun 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc