func unlock(lock lockfile.Lockfile) error { locksMu.Lock() defer locksMu.Unlock() if _, ok := locks[lock]; !ok { return nil } delete(locks, lock) return lock.Unlock() }
func tryLock(lock lockfile.Lockfile) error { locksMu.Lock() defer locksMu.Unlock() if _, ok := locks[lock]; ok { return errors.New("file in use") } if err := lock.TryLock(); err != nil { return err } locks[lock] = struct{}{} return nil }