single

package module
v0.0.0-...-9f8d812 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2020 License: MIT Imports: 6 Imported by: 33

README

single

This package will no longer be maintained, please use github.com/postfinance/single instead.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyRunning -- the instance is already running
	ErrAlreadyRunning = errors.New("the program is already running")
	// Lockfile -- the lock file to check
	Lockfile string
)

Functions

This section is empty.

Types

type Single

type Single struct {
	// contains filtered or unexported fields
}

Single represents the name and the open file descriptor

func New

func New(name string) *Single

New creates a Single instance

func (*Single) CheckLock

func (s *Single) CheckLock() error

CheckLock tries to obtain an exclude lock on a lockfile and returns an error if one occurs

func (*Single) Filename

func (s *Single) Filename() string

Filename returns an absolute filename, appropriate for the operating system

func (*Single) Lock

func (s *Single) Lock()

Lock tries to obtain an exclude lock on a lockfile and exits the program if an error occurs

func (*Single) TryUnlock

func (s *Single) TryUnlock() error

TryUnlock unlocks, closes and removes the lockfile

func (*Single) Unlock

func (s *Single) Unlock()

Unlock releases the lock, closes and removes the lockfile. All errors will be reported directly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL