Package lockutil contains a file based lock which can be used to lock file resources across different processes. The lock file is monitored by a Go routine. Invalidating the lock file (e.g. just writing a single character to it) causes the Go routine to exit. A client can check if the lockfile is still being monitored by calling WatcherRunning().



    This section is empty.


    This section is empty.


    This section is empty.


    type LockFile

    type LockFile struct {
    	// contains filtered or unexported fields

      LockFile data structure

      func NewLockFile

      func NewLockFile(filename string, interval time.Duration) *LockFile

        NewLockFile creates a new LockFile which and watch it in given intervals.

        func (*LockFile) Finish

        func (lf *LockFile) Finish() error

          Finish watching a lockfile and return once the watcher goroutine has finished.

          func (*LockFile) SetWatcherRunning

          func (lf *LockFile) SetWatcherRunning(state bool)

            SetWatcherRunning sets if the watcher goroutine is running.

            func (*LockFile) Start

            func (lf *LockFile) Start() error

              Start creates the lockfile and starts watching it.

              func (*LockFile) WatcherRunning

              func (lf *LockFile) WatcherRunning() bool

                WatcherRunning returns if the watcher goroutine is running.

                Source Files