Skip to content

Commit 6d66d82

Browse files
authored
Merge pull request #19475 from henrybear327/ci/address_linter_issues
Address issues reported by golangci-lint after bumping the version to v1.64.5
2 parents 628435a + 43df62f commit 6d66d82

7 files changed

+59
-59
lines changed

tests/integration/clientv3/examples/example_cluster_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222
clientv3 "go.etcd.io/etcd/client/v3"
2323
)
2424

25-
func mockCluster_memberList() {
25+
func mockClusterMemberList() {
2626
fmt.Println("members: 3")
2727
}
2828

2929
func ExampleCluster_memberList() {
30-
forUnitTestsRunInMockedContext(mockCluster_memberList, func() {
30+
forUnitTestsRunInMockedContext(mockClusterMemberList, func() {
3131
cli, err := clientv3.New(clientv3.Config{
3232
Endpoints: exampleEndpoints(),
3333
DialTimeout: dialTimeout,
@@ -46,13 +46,13 @@ func ExampleCluster_memberList() {
4646
// Output: members: 3
4747
}
4848

49-
func mockCluster_memberAdd() {
49+
func mockClusterMemberAdd() {
5050
fmt.Println("added member.PeerURLs: [http://localhost:32380]")
5151
fmt.Println("members count: 4")
5252
}
5353

5454
func ExampleCluster_memberAdd() {
55-
forUnitTestsRunInMockedContext(mockCluster_memberAdd, func() {
55+
forUnitTestsRunInMockedContext(mockClusterMemberAdd, func() {
5656
cli, err := clientv3.New(clientv3.Config{
5757
Endpoints: exampleEndpoints(),
5858
DialTimeout: dialTimeout,
@@ -81,13 +81,13 @@ func ExampleCluster_memberAdd() {
8181
// members count: 4
8282
}
8383

84-
func mockCluster_memberAddAsLearner() {
84+
func mockClusterMemberAddAsLearner() {
8585
fmt.Println("members count: 4")
8686
fmt.Println("added member.IsLearner: true")
8787
}
8888

8989
func ExampleCluster_memberAddAsLearner() {
90-
forUnitTestsRunInMockedContext(mockCluster_memberAddAsLearner, func() {
90+
forUnitTestsRunInMockedContext(mockClusterMemberAddAsLearner, func() {
9191
cli, err := clientv3.New(clientv3.Config{
9292
Endpoints: exampleEndpoints(),
9393
DialTimeout: dialTimeout,
@@ -116,10 +116,10 @@ func ExampleCluster_memberAddAsLearner() {
116116
// added member.IsLearner: true
117117
}
118118

119-
func mockCluster_memberRemove() {}
119+
func mockClusterMemberRemove() {}
120120

121121
func ExampleCluster_memberRemove() {
122-
forUnitTestsRunInMockedContext(mockCluster_memberRemove, func() {
122+
forUnitTestsRunInMockedContext(mockClusterMemberRemove, func() {
123123
cli, err := clientv3.New(clientv3.Config{
124124
Endpoints: exampleEndpoints(),
125125
DialTimeout: dialTimeout,
@@ -147,10 +147,10 @@ func ExampleCluster_memberRemove() {
147147
})
148148
}
149149

150-
func mockCluster_memberUpdate() {}
150+
func mockClusterMemberUpdate() {}
151151

152152
func ExampleCluster_memberUpdate() {
153-
forUnitTestsRunInMockedContext(mockCluster_memberUpdate, func() {
153+
forUnitTestsRunInMockedContext(mockClusterMemberUpdate, func() {
154154
cli, err := clientv3.New(clientv3.Config{
155155
Endpoints: exampleEndpoints(),
156156
DialTimeout: dialTimeout,

tests/integration/clientv3/examples/example_kv_test.go

+23-23
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ package clientv3_test
1616

1717
import (
1818
"context"
19+
"errors"
1920
"fmt"
2021
"log"
2122

2223
"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
2324
clientv3 "go.etcd.io/etcd/client/v3"
2425
)
2526

26-
func mockKV_put() {}
27+
func mockKVPut() {}
2728

2829
func ExampleKV_put() {
29-
forUnitTestsRunInMockedContext(mockKV_put, func() {
30+
forUnitTestsRunInMockedContext(mockKVPut, func() {
3031
cli, err := clientv3.New(clientv3.Config{
3132
Endpoints: exampleEndpoints(),
3233
DialTimeout: dialTimeout,
@@ -46,12 +47,12 @@ func ExampleKV_put() {
4647
// Output:
4748
}
4849

49-
func mockKV_putErrorHandling() {
50+
func mockKVPutErrorHandling() {
5051
fmt.Println("client-side error: etcdserver: key is not provided")
5152
}
5253

5354
func ExampleKV_putErrorHandling() {
54-
forUnitTestsRunInMockedContext(mockKV_putErrorHandling, func() {
55+
forUnitTestsRunInMockedContext(mockKVPutErrorHandling, func() {
5556
cli, err := clientv3.New(clientv3.Config{
5657
Endpoints: exampleEndpoints(),
5758
DialTimeout: dialTimeout,
@@ -65,27 +66,26 @@ func ExampleKV_putErrorHandling() {
6566
_, err = cli.Put(ctx, "", "sample_value")
6667
cancel()
6768
if err != nil {
68-
switch err {
69-
case context.Canceled:
69+
if errors.Is(err, context.Canceled) {
7070
fmt.Printf("ctx is canceled by another routine: %v\n", err)
71-
case context.DeadlineExceeded:
71+
} else if errors.Is(err, context.DeadlineExceeded) {
7272
fmt.Printf("ctx is attached with a deadline is exceeded: %v\n", err)
73-
case rpctypes.ErrEmptyKey:
73+
} else if errors.Is(err, rpctypes.ErrEmptyKey) {
7474
fmt.Printf("client-side error: %v\n", err)
75-
default:
75+
} else {
7676
fmt.Printf("bad cluster endpoints, which are not etcd servers: %v\n", err)
7777
}
7878
}
7979
})
8080
// Output: client-side error: etcdserver: key is not provided
8181
}
8282

83-
func mockKV_get() {
83+
func mockKVGet() {
8484
fmt.Println("foo : bar")
8585
}
8686

8787
func ExampleKV_get() {
88-
forUnitTestsRunInMockedContext(mockKV_get, func() {
88+
forUnitTestsRunInMockedContext(mockKVGet, func() {
8989
cli, err := clientv3.New(clientv3.Config{
9090
Endpoints: exampleEndpoints(),
9191
DialTimeout: dialTimeout,
@@ -113,12 +113,12 @@ func ExampleKV_get() {
113113
// Output: foo : bar
114114
}
115115

116-
func mockKV_getWithRev() {
116+
func mockKVGetWithRev() {
117117
fmt.Println("foo : bar1")
118118
}
119119

120120
func ExampleKV_getWithRev() {
121-
forUnitTestsRunInMockedContext(mockKV_getWithRev, func() {
121+
forUnitTestsRunInMockedContext(mockKVGetWithRev, func() {
122122
cli, err := clientv3.New(clientv3.Config{
123123
Endpoints: exampleEndpoints(),
124124
DialTimeout: dialTimeout,
@@ -150,14 +150,14 @@ func ExampleKV_getWithRev() {
150150
// Output: foo : bar1
151151
}
152152

153-
func mockKV_getSortedPrefix() {
153+
func mockKVGetSortedPrefix() {
154154
fmt.Println(`key_2 : value`)
155155
fmt.Println(`key_1 : value`)
156156
fmt.Println(`key_0 : value`)
157157
}
158158

159159
func ExampleKV_getSortedPrefix() {
160-
forUnitTestsRunInMockedContext(mockKV_getSortedPrefix, func() {
160+
forUnitTestsRunInMockedContext(mockKVGetSortedPrefix, func() {
161161
cli, err := clientv3.New(clientv3.Config{
162162
Endpoints: exampleEndpoints(),
163163
DialTimeout: dialTimeout,
@@ -192,12 +192,12 @@ func ExampleKV_getSortedPrefix() {
192192
// key_0 : value
193193
}
194194

195-
func mockKV_delete() {
195+
func mockKVDelete() {
196196
fmt.Println("Deleted all keys: true")
197197
}
198198

199199
func ExampleKV_delete() {
200-
forUnitTestsRunInMockedContext(mockKV_delete, func() {
200+
forUnitTestsRunInMockedContext(mockKVDelete, func() {
201201
cli, err := clientv3.New(clientv3.Config{
202202
Endpoints: exampleEndpoints(),
203203
DialTimeout: dialTimeout,
@@ -228,10 +228,10 @@ func ExampleKV_delete() {
228228
// Deleted all keys: true
229229
}
230230

231-
func mockKV_compact() {}
231+
func mockKVCompact() {}
232232

233233
func ExampleKV_compact() {
234-
forUnitTestsRunInMockedContext(mockKV_compact, func() {
234+
forUnitTestsRunInMockedContext(mockKVCompact, func() {
235235
cli, err := clientv3.New(clientv3.Config{
236236
Endpoints: exampleEndpoints(),
237237
DialTimeout: dialTimeout,
@@ -259,12 +259,12 @@ func ExampleKV_compact() {
259259
// Output:
260260
}
261261

262-
func mockKV_txn() {
262+
func mockKVTxn() {
263263
fmt.Println("key : XYZ")
264264
}
265265

266266
func ExampleKV_txn() {
267-
forUnitTestsRunInMockedContext(mockKV_txn, func() {
267+
forUnitTestsRunInMockedContext(mockKVTxn, func() {
268268
cli, err := clientv3.New(clientv3.Config{
269269
Endpoints: exampleEndpoints(),
270270
DialTimeout: dialTimeout,
@@ -306,10 +306,10 @@ func ExampleKV_txn() {
306306
// Output: key : XYZ
307307
}
308308

309-
func mockKV_do() {}
309+
func mockKVDo() {}
310310

311311
func ExampleKV_do() {
312-
forUnitTestsRunInMockedContext(mockKV_do, func() {
312+
forUnitTestsRunInMockedContext(mockKVDo, func() {
313313
cli, err := clientv3.New(clientv3.Config{
314314
Endpoints: exampleEndpoints(),
315315
DialTimeout: dialTimeout,

tests/integration/clientv3/examples/example_lease_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import (
2222
clientv3 "go.etcd.io/etcd/client/v3"
2323
)
2424

25-
func mockLease_grant() {
25+
func mockLeaseGrant() {
2626
}
2727

2828
func ExampleLease_grant() {
29-
forUnitTestsRunInMockedContext(mockLease_grant, func() {
29+
forUnitTestsRunInMockedContext(mockLeaseGrant, func() {
3030
cli, err := clientv3.New(clientv3.Config{
3131
Endpoints: exampleEndpoints(),
3232
DialTimeout: dialTimeout,
@@ -51,12 +51,12 @@ func ExampleLease_grant() {
5151
// Output:
5252
}
5353

54-
func mockLease_revoke() {
54+
func mockLeaseRevoke() {
5555
fmt.Println("number of keys: 0")
5656
}
5757

5858
func ExampleLease_revoke() {
59-
forUnitTestsRunInMockedContext(mockLease_revoke, func() {
59+
forUnitTestsRunInMockedContext(mockLeaseRevoke, func() {
6060
cli, err := clientv3.New(clientv3.Config{
6161
Endpoints: exampleEndpoints(),
6262
DialTimeout: dialTimeout,
@@ -91,12 +91,12 @@ func ExampleLease_revoke() {
9191
// Output: number of keys: 0
9292
}
9393

94-
func mockLease_keepAlive() {
94+
func mockLeaseKeepAlive() {
9595
fmt.Println("ttl: 5")
9696
}
9797

9898
func ExampleLease_keepAlive() {
99-
forUnitTestsRunInMockedContext(mockLease_keepAlive, func() {
99+
forUnitTestsRunInMockedContext(mockLeaseKeepAlive, func() {
100100
cli, err := clientv3.New(clientv3.Config{
101101
Endpoints: exampleEndpoints(),
102102
DialTimeout: dialTimeout,
@@ -132,12 +132,12 @@ func ExampleLease_keepAlive() {
132132
// Output: ttl: 5
133133
}
134134

135-
func mockLease_keepAliveOnce() {
135+
func mockLeaseKeepAliveOnce() {
136136
fmt.Println("ttl: 5")
137137
}
138138

139139
func ExampleLease_keepAliveOnce() {
140-
forUnitTestsRunInMockedContext(mockLease_keepAliveOnce, func() {
140+
forUnitTestsRunInMockedContext(mockLeaseKeepAliveOnce, func() {
141141
cli, err := clientv3.New(clientv3.Config{
142142
Endpoints: exampleEndpoints(),
143143
DialTimeout: dialTimeout,

tests/integration/clientv3/examples/example_maintenance_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import (
2121
clientv3 "go.etcd.io/etcd/client/v3"
2222
)
2323

24-
func mockMaintenance_status() {}
24+
func mockMaintenanceStatus() {}
2525

2626
func ExampleMaintenance_status() {
27-
forUnitTestsRunInMockedContext(mockMaintenance_status, func() {
27+
forUnitTestsRunInMockedContext(mockMaintenanceStatus, func() {
2828
for _, ep := range exampleEndpoints() {
2929
cli, err := clientv3.New(clientv3.Config{
3030
Endpoints: []string{ep},
@@ -44,10 +44,10 @@ func ExampleMaintenance_status() {
4444
// Output:
4545
}
4646

47-
func mockMaintenance_defragment() {}
47+
func mockMaintenanceDefragment() {}
4848

4949
func ExampleMaintenance_defragment() {
50-
forUnitTestsRunInMockedContext(mockMaintenance_defragment, func() {
50+
forUnitTestsRunInMockedContext(mockMaintenanceDefragment, func() {
5151
for _, ep := range exampleEndpoints() {
5252
cli, err := clientv3.New(clientv3.Config{
5353
Endpoints: []string{ep},

tests/integration/clientv3/examples/example_metrics_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ import (
3131
clientv3 "go.etcd.io/etcd/client/v3"
3232
)
3333

34-
func mockClient_metrics() {
34+
func mockClientMetrics() {
3535
fmt.Println(`grpc_client_started_total{grpc_method="Range",grpc_service="etcdserverpb.KV",grpc_type="unary"} 1`)
3636
}
3737

3838
func ExampleClient_metrics() {
39-
forUnitTestsRunInMockedContext(mockClient_metrics, func() {
39+
forUnitTestsRunInMockedContext(mockClientMetrics, func() {
4040
clientMetrics := grpcprom.NewClientMetrics()
4141
prometheus.Register(clientMetrics)
4242
cli, err := clientv3.New(clientv3.Config{

tests/integration/clientv3/examples/example_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import (
2222
clientv3 "go.etcd.io/etcd/client/v3"
2323
)
2424

25-
func mockConfig_insecure() {}
25+
func mockConfigInsecure() {}
2626

2727
func ExampleConfig_insecure() {
28-
forUnitTestsRunInMockedContext(mockConfig_insecure, func() {
28+
forUnitTestsRunInMockedContext(mockConfigInsecure, func() {
2929
cli, err := clientv3.New(clientv3.Config{
3030
Endpoints: exampleEndpoints(),
3131
DialTimeout: dialTimeout,
@@ -46,10 +46,10 @@ func ExampleConfig_insecure() {
4646
// Output:
4747
}
4848

49-
func mockConfig_withTLS() {}
49+
func mockConfigWithTLS() {}
5050

5151
func ExampleConfig_withTLS() {
52-
forUnitTestsRunInMockedContext(mockConfig_withTLS, func() {
52+
forUnitTestsRunInMockedContext(mockConfigWithTLS, func() {
5353
tlsInfo := transport.TLSInfo{
5454
CertFile: "/tmp/test-certs/test-name-1.pem",
5555
KeyFile: "/tmp/test-certs/test-name-1-key.pem",

0 commit comments

Comments
 (0)