etcd.go 334 B

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