标签:cli tab use cond conf user exec dock 选择
package main
import (
"context"
"go.etcd.io/etcd/clientv3"
"time"
)
func main() {
config := clientv3.Config{
Endpoints: []string{"106.12.72.181:23791", "106.12.72.181:23792"},
DialTimeout: 10 * time.Second,
}
client, _ := clientv3.New(config)
defer client.Close()
kv := clientv3.NewKV(client)
ctx := context.Background() //需要放入一个context,看自己需求选择合适的ctx
kv.Put(ctx,"/services/user","user1") //插入一条数据
}
root@instance-emh5jlpa:~# docker exec -it etcd1 sh
/go # etcdctl get /services/user
/services/user
user1
/go # exit
root@instance-emh5jlpa:~# docker exec -it etcd2 sh
/go # etcdctl get /services/user
/services/user
user1
标签:cli tab use cond conf user exec dock 选择
原文地址:https://www.cnblogs.com/hualou/p/12071067.html