mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-01-03 21:26:30 +00:00
14 lines
269 B
Go
14 lines
269 B
Go
|
//go:build !unix
|
||
|
|
||
|
package dotlk
|
||
|
|
||
|
import "os"
|
||
|
|
||
|
// TryLock returns nil if it acquired the lock,
|
||
|
// fs.ErrExist if another process has the lock.
|
||
|
func TryLock(name string) error {
|
||
|
f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666)
|
||
|
f.Close()
|
||
|
return err
|
||
|
}
|