ergo/irc/flock/flock.go
Shivaram Lingamneni df6aa4c34b
Some checks failed
build / build (push) Has been cancelled
ghcr / Build (push) Has been cancelled
enable building for solaris (#2183)
2024-08-02 15:09:28 -04:00

24 lines
404 B
Go

//go:build !(plan9 || solaris)
package flock
import (
"errors"
"github.com/gofrs/flock"
)
var (
CouldntAcquire = errors.New("Couldn't acquire flock (is another Ergo running?)")
)
func TryAcquireFlock(path string) (fl Flocker, err error) {
f := flock.New(path)
success, err := f.TryLock()
if err != nil {
return nil, err
} else if !success {
return nil, CouldntAcquire
}
return f, nil
}