mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
20 lines
320 B
Go
20 lines
320 B
Go
package flock
|
|
|
|
import "os"
|
|
|
|
type plan9Lock struct {
|
|
f *os.File
|
|
}
|
|
|
|
func (l *plan9Lock) Release() error {
|
|
return l.f.Close()
|
|
}
|
|
|
|
func newLock(fileName string) (Releaser, error) {
|
|
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, os.ModeExclusive|0644)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &plan9Lock{f}, nil
|
|
}
|