plugins/vendor/github.com/alexflint/go-filemutex
dependabot[bot] 615420fa9f build(deps): bump github.com/alexflint/go-filemutex from 1.1.0 to 1.2.0
Bumps [github.com/alexflint/go-filemutex](https://github.com/alexflint/go-filemutex) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/alexflint/go-filemutex/releases)
- [Commits](https://github.com/alexflint/go-filemutex/compare/v1.1...v1.2.0)

---
updated-dependencies:
- dependency-name: github.com/alexflint/go-filemutex
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2022-12-26 21:36:15 +00:00
..
filemutex_flock.go build(deps): bump github.com/alexflint/go-filemutex from 1.1.0 to 1.2.0 2022-12-26 21:36:15 +00:00
filemutex_windows.go build(deps): bump github.com/alexflint/go-filemutex from 1.1.0 to 1.2.0 2022-12-26 21:36:15 +00:00
filemutex.go go.mod: github.com/alexflint/go-filemutex v1.1.0 2021-04-09 00:07:30 +02:00
LICENSE Update Vendor 2018-09-21 00:34:07 +08:00
README.md host-local: Update host-local IPAM to support Windows 2017-11-11 15:17:45 -08:00

FileMutex

FileMutex is similar to sync.RWMutex, but also synchronizes across processes. On Linux, OSX, and other POSIX systems it uses the flock system call. On windows it uses the LockFileEx and UnlockFileEx system calls.

import (
	"log"
	"github.com/alexflint/go-filemutex"
)

func main() {
	m, err := filemutex.New("/tmp/foo.lock")
	if err != nil {
		log.Fatalln("Directory did not exist or file could not created")
	}

	m.Lock()  // Will block until lock can be acquired

	// Code here is protected by the mutex

	m.Unlock()
}

Installation

go get github.com/alexflint/go-filemutex

Forked from https://github.com/golang/build/tree/master/cmd/builder/filemutex_*.go