Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseHandle ¶
func CloseHandle(fd FileHandle)
CloseHandle closes a file handle without unlocking
WARNING: This is a last-resort function for error handling only! On Unix systems, closing a file descriptor automatically releases any locks, so "closing without unlocking" is impossible. This function will release the lock as a side effect of closing the file.
This function should only be used in error paths where the lock state is already corrupted or when giving up on lock management entirely. Normal code should use UnlockAndCloseHandle instead.
func TryLockFile ¶
func TryLockFile(fd FileHandle, lockType LockType) error
TryLockFile attempts to lock a file handle
func UnlockAndCloseHandle ¶
func UnlockAndCloseHandle(fd FileHandle)
UnlockAndClose unlocks and closes a file handle
Types ¶
type FileHandle ¶
type FileHandle = fileHandle
func OpenLock ¶
func OpenLock(path string, readOnly bool) (FileHandle, error)
OpenLock opens a file for locking WARNING: This is the underlying file locking primitive of the OS; because closing FileHandle releases the lock, it is not suitable for use if there is any chance of two concurrent goroutines attempting to use the same lock. Most users should use the higher-level operations from internal/staging_lockfile or pkg/lockfile.