mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +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
|
||
|
|
}
|