Skip to content

Commit 321879d

Browse files
committed
add 添加Etcd用法
1 parent a2cbf15 commit 321879d

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

go.mod

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ require (
1515
github.com/nats-io/nats.go v1.13.1-0.20211122170419-d7c1d78a50fc
1616
github.com/nsqio/go-nsq v1.1.0
1717
github.com/satori/go.uuid v1.2.0
18-
github.com/simonalong/gole v1.0.2-0.20220308121856-76eab114d3d5
1918
github.com/simonalong/mikilin-go v1.0.2-0.20211208074724-b25f05b74f31
2019
github.com/sirupsen/logrus v1.8.1
2120
go.etcd.io/etcd/client/v3 v3.5.3
@@ -42,7 +41,7 @@ require (
4241
github.com/json-iterator/go v1.1.12 // indirect
4342
github.com/leodido/go-urn v1.2.1 // indirect
4443
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect
45-
github.com/lestrrat-go/strftime v1.0.5 // indirect
44+
github.com/lestrrat-go/strftime v1.0.6 // indirect
4645
github.com/mattn/go-isatty v0.0.14 // indirect; indirect¬¬¬
4746
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4847
github.com/modern-go/reflect2 v1.0.2 // indirect
@@ -57,14 +56,14 @@ require (
5756
go.uber.org/atomic v1.7.0 // indirect
5857
go.uber.org/multierr v1.6.0 // indirect
5958
go.uber.org/zap v1.17.0 // indirect
60-
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
59+
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
6160
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
62-
golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7 // indirect
61+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
6362
golang.org/x/text v0.3.7 // indirect
6463
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
6564
google.golang.org/genproto v0.0.0-20210813162853-db860fec028c // indirect
6665
google.golang.org/grpc v1.39.1 // indirect
67-
google.golang.org/protobuf v1.27.1 // indirect
66+
google.golang.org/protobuf v1.28.0 // indirect
6867
xorm.io/builder v0.3.6 // indirect
6968
xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb
7069
)

go.sum

+9
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkL
276276
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
277277
github.com/lestrrat-go/strftime v1.0.5 h1:A7H3tT8DhTz8u65w+JRpiBxM4dINQhUXAZnhBa2xeOE=
278278
github.com/lestrrat-go/strftime v1.0.5/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g=
279+
github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ=
280+
github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw=
279281
github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
280282
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
281283
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
@@ -394,6 +396,7 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
394396
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
395397
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
396398
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
399+
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
397400
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
398401
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
399402
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
@@ -444,6 +447,8 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y
444447
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
445448
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 h1:syTAU9FwmvzEoIYMqcPHOcVm4H3U5u90WsvuYgwpETU=
446449
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
450+
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
451+
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
447452
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
448453
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
449454
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -613,6 +618,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
613618
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
614619
golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7 h1:8IVLkfbr2cLhv0a/vKq4UFUcJym8RmDoDboxCFWEjYE=
615620
golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
621+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
622+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
616623
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
617624
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
618625
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -818,6 +825,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
818825
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
819826
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
820827
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
828+
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
829+
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
821830
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
822831
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
823832
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

src/etcd/etcdDemo_test.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var (
1818

1919
var Ctx = context.Background()
2020

21-
func TestEtcd0(t *testing.T) {
21+
func init() {
2222
// 客户端配置
2323
config = clientv3.Config{
2424
Endpoints: []string{"10.30.30.78:22379"},
@@ -31,7 +31,6 @@ func TestEtcd0(t *testing.T) {
3131
fmt.Println(err)
3232
return
3333
}
34-
3534
fmt.Println("ok")
3635
}
3736

@@ -57,9 +56,9 @@ func TestEtcd1(t *testing.T) {
5756
}
5857

5958
func TestKeys(t *testing.T) {
60-
etcdClient.Put(Ctx, "test:k1", "v2")
61-
etcdClient.Put(Ctx, "test:k1/k1", "v2")
62-
etcdClient.Put(Ctx, "test:k1/k3", "v2")
59+
etcdClient.Put(Ctx, "test:key1", "v2")
60+
etcdClient.Put(Ctx, "test:key1/k1", "v2")
61+
etcdClient.Put(Ctx, "test:key1/k3", "v2")
6362
etcdClient.Put(Ctx, "test:k2", "v2")
6463
etcdClient.Put(Ctx, "test:k3", "v2")
6564
etcdClient.Put(Ctx, "test:k4", "v2")

0 commit comments

Comments
 (0)