Documentation ¶
Overview ¶
Package lock provides methods for working with lock files
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Dir = "/var/tmp"
Dir is a path to directory with lock files
Functions ¶
func Create ¶
Create creates new lock file
Example ¶
err := Create("my_app") if err != nil { panic(err.Error()) } // do some stuff err = Remove("my_app") if err != nil { panic(err.Error()) }
Output:
func Has ¶
Has returns true if lock file exists
Example ¶
if Has("my_app") { panic("Can't start application due to lock file") }
Output:
func IsExpired ¶
IsExpired returns true if lock file reached TTL
Example ¶
if Has("my_app") { if IsExpired("my_app", time.Hour) { // looks like lock file was created long time ago, so delete it Remove("my_app") } else { panic("Can't start application due to lock file") } }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.