//go:build !windows package database import ( "errors" "os" "golang.org/x/sys/unix" ) func tryMaintenanceFileLock(file *os.File, exclusive bool) (bool, error) { mode := unix.LOCK_SH if exclusive { mode = unix.LOCK_EX } err := unix.Flock(int(file.Fd()), mode|unix.LOCK_NB) if errors.Is(err, unix.EWOULDBLOCK) { return false, nil } return err == nil, err } func unlockMaintenanceFile(file *os.File) error { return unix.Flock(int(file.Fd()), unix.LOCK_UN) }