下载库:
go get -u github.com/wzbwzt/dlock
使用事例:
etcd := etcd.NewRegister(etcd.WithTimeOut(time.Second * 5))
lock := dlock.NewDlock(dlock.WithRegister(etcd))
//获取etcd的客户端
// etcdclient:=etcd.GetEtcdClient()
path := "/lock/a"
lock.Lock(path, time.Second*10)
defer lock.UnLock(path)