Open
Description
If the lock fails because of some reason other than it being already
locked, it would be nice to be able to tell that other than
with string comparison and checking .Temporary().
This would make it easer to implement blocking locks
based around a backoff-and-retry strategy (you probably
don't want to retry if you're getting EPERM for example).
For example (as an addition to the API):
// LockedError records an error that occurs when
// a file is already locked.
type LockedError struct {
File string
}
func (e *LockedError) Error() string {
return fmt.Sprintf("file %q already locked", e.File)
}
// IsLocked reports whether the error is due to
// a file being already locked.
func IsLocked(err error) bool {
_, ok := err.(*LockedError)
return ok
}
Metadata
Metadata
Assignees
Labels
No labels