Documentation
¶
Overview ¶
Package filelock provides locked File struct similar with os.File.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrLocked = LockError{errors.New("locked")}
)
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents an open file descriptor such as os.File. But File always has Posix write lock.
func Acquire ¶
func Acquire(ctx context.Context, name string, perm os.FileMode, period time.Duration) (*File, error)
Acquire tries to obtain file lock given period.
func Create ¶
Create creates or opens the named file with OpenFile. When an error occurs, Create returns OpenFile error. If the file already exists, it is not truncated as with os.Create. If the file does not exist, it is created with mode perm (before umask). If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode os.O_RDWR.
func Open ¶
Open opens the named file with OpenFile for reading. When an error occurs, Open returns the error like OpenFile. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode os.O_RDONLY.