etcd.go 308 B

123456789101112131415161718192021222324
  1. package etcd
  2. import (
  3. "strings"
  4. clientv3 "go.etcd.io/etcd/client/v3"
  5. )
  6. var cli *clientv3.Client
  7. func Init(addr string) {
  8. var err error
  9. cli, err = clientv3.New(clientv3.Config{
  10. Endpoints: strings.Split(addr, ","),
  11. })
  12. if err != nil {
  13. panic(err)
  14. }
  15. }
  16. func Get() *clientv3.Client {
  17. return cli
  18. }