Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
a minimal program that obtains a golock lock. compile to "testlock" with go build testlock.go
package main
import (
func main() {
ln := lock.GetenvLockName()
if ln == "" {
fmt.Printf("no lock name\n")
lck,lck_err := lock.New(ln)
if lck_err != nil {
fmt.Printf("cannot lock:%s\n",lck_err.Error())
time.Sleep(time.Duration(10) * time.Second)
_ = lck.Release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.