Skip to content

Commit 4e47475

Browse files
authored
clean some linter errors and remove use of ioutils as it's deprecated (#529)
1 parent a3acea6 commit 4e47475

12 files changed

+41
-100
lines changed

file_snapshot.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"hash"
1212
"hash/crc64"
1313
"io"
14-
"io/ioutil"
1514
"os"
1615
"path/filepath"
1716
"runtime"
@@ -245,7 +244,7 @@ func (f *FileSnapshotStore) List() ([]*SnapshotMeta, error) {
245244
// getSnapshots returns all the known snapshots.
246245
func (f *FileSnapshotStore) getSnapshots() ([]*fileSnapshotMeta, error) {
247246
// Get the eligible snapshots
248-
snapshots, err := ioutil.ReadDir(f.path)
247+
snapshots, err := os.ReadDir(f.path)
249248
if err != nil {
250249
f.logger.Error("failed to scan snapshot directory", "error", err)
251250
return nil, err

file_snapshot_test.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package raft
66
import (
77
"bytes"
88
"io"
9-
"io/ioutil"
109
"os"
1110
"reflect"
1211
"runtime"
@@ -28,13 +27,13 @@ func TestFileSnapshotSinkImpl(t *testing.T) {
2827
}
2928

3029
func TestFileSS_CreateSnapshotMissingParentDir(t *testing.T) {
31-
parent, err := ioutil.TempDir("", "raft")
30+
parent, err := os.MkdirTemp("", "raft")
3231
if err != nil {
3332
t.Fatalf("err: %v ", err)
3433
}
3534
defer os.RemoveAll(parent)
3635

37-
dir, err := ioutil.TempDir(parent, "raft")
36+
dir, err := os.MkdirTemp(parent, "raft")
3837
if err != nil {
3938
t.Fatalf("err: %v ", err)
4039
}
@@ -54,7 +53,7 @@ func TestFileSS_CreateSnapshotMissingParentDir(t *testing.T) {
5453
}
5554
func TestFileSS_CreateSnapshot(t *testing.T) {
5655
// Create a test dir
57-
dir, err := ioutil.TempDir("", "raft")
56+
dir, err := os.MkdirTemp("", "raft")
5857
if err != nil {
5958
t.Fatalf("err: %v ", err)
6059
}
@@ -162,7 +161,7 @@ func TestFileSS_CreateSnapshot(t *testing.T) {
162161

163162
func TestFileSS_CancelSnapshot(t *testing.T) {
164163
// Create a test dir
165-
dir, err := ioutil.TempDir("", "raft")
164+
dir, err := os.MkdirTemp("", "raft")
166165
if err != nil {
167166
t.Fatalf("err: %v ", err)
168167
}
@@ -200,7 +199,7 @@ func TestFileSS_Retention(t *testing.T) {
200199
var err error
201200
// Create a test dir
202201
var dir string
203-
dir, err = ioutil.TempDir("", "raft")
202+
dir, err = os.MkdirTemp("", "raft")
204203
if err != nil {
205204
t.Fatalf("err: %v ", err)
206205
}
@@ -253,15 +252,15 @@ func TestFileSS_BadPerm(t *testing.T) {
253252

254253
// Create a temp dir
255254
var dir1 string
256-
dir1, err = ioutil.TempDir("", "raft")
255+
dir1, err = os.MkdirTemp("", "raft")
257256
if err != nil {
258257
t.Fatalf("err: %s", err)
259258
}
260259
defer os.RemoveAll(dir1)
261260

262261
// Create a sub dir and remove all permissions
263262
var dir2 string
264-
dir2, err = ioutil.TempDir(dir1, "badperm")
263+
dir2, err = os.MkdirTemp(dir1, "badperm")
265264
if err != nil {
266265
t.Fatalf("err: %s", err)
267266
}
@@ -277,13 +276,13 @@ func TestFileSS_BadPerm(t *testing.T) {
277276
}
278277

279278
func TestFileSS_MissingParentDir(t *testing.T) {
280-
parent, err := ioutil.TempDir("", "raft")
279+
parent, err := os.MkdirTemp("", "raft")
281280
if err != nil {
282281
t.Fatalf("err: %v ", err)
283282
}
284283
defer os.RemoveAll(parent)
285284

286-
dir, err := ioutil.TempDir(parent, "raft")
285+
dir, err := os.MkdirTemp(parent, "raft")
287286
if err != nil {
288287
t.Fatalf("err: %v ", err)
289288
}
@@ -297,7 +296,7 @@ func TestFileSS_MissingParentDir(t *testing.T) {
297296

298297
func TestFileSS_Ordering(t *testing.T) {
299298
// Create a test dir
300-
dir, err := ioutil.TempDir("", "raft")
299+
dir, err := os.MkdirTemp("", "raft")
301300
if err != nil {
302301
t.Fatalf("err: %v ", err)
303302
}

fuzzy/cluster.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"bytes"
88
"fmt"
99
"io"
10-
"io/ioutil"
1110
"os"
1211
"path/filepath"
1312
"testing"
@@ -294,7 +293,7 @@ func (c *cluster) VerifyFSM(t *testing.T) {
294293
}
295294

296295
func (c *cluster) RecordState(t *testing.T) {
297-
td, _ := ioutil.TempDir(os.Getenv("TEST_FAIL_DIR"), "failure")
296+
td, _ := os.MkdirTemp(os.Getenv("TEST_FAIL_DIR"), "failure")
298297
sd, _ := resolveDirectory("data", false)
299298
copyDir(td, sd)
300299
dump := func(n *raftNode) {

fuzzy/go.sum

-23
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,21 @@ github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp
99
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1010
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1111
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
12-
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
13-
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
1412
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
1513
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
1614
github.com/hashicorp/go-hclog v0.9.1 h1:9PZfAcVEvez4yhLH2TBU64/h/z4xlFI80cWXRrxuKuM=
1715
github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
18-
github.com/hashicorp/go-hclog v0.16.0 h1:uCeOEwSWGMwhJUdpUjk+1cVKIEfGu2/1nFXukimi2MU=
19-
github.com/hashicorp/go-hclog v0.16.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
2016
github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=
2117
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
2218
github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI=
2319
github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
24-
github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6KvJWs=
25-
github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4=
2620
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
2721
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
2822
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
2923
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
3024
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
3125
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea h1:xykPFhrBAS2J0VBzVa5e80b5ZtYuNQtgXjN40qBZlD4=
3226
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk=
33-
github.com/hashicorp/raft-boltdb v0.0.0-20210409134258-03c10cc3d4ea h1:RxcPJuutPRM8PUOyiweMmkuNO+RJyfy2jds2gfvgNmU=
34-
github.com/hashicorp/raft-boltdb v0.0.0-20210409134258-03c10cc3d4ea/go.mod h1:qRd6nFJYYS6Iqnc/8HcUmko2/2Gw8qTFEmxDLii6W5I=
35-
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
36-
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
37-
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
38-
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
39-
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
4027
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
4128
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
4229
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
@@ -52,17 +39,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
5239
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
5340
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
5441
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
55-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
5642
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
57-
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
5843
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
59-
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
60-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
61-
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
62-
golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
63-
golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU=
64-
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6544
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0 h1:g9s1Ppvvun/fI+BptTMj909BBIcGrzQ32k9FNlcevOE=
6645
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
67-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
68-
golang.org/x/tools v0.0.0-20190424220101-1e8e1cfdf96b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=

inmem_snapshot.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"bytes"
88
"fmt"
99
"io"
10-
"io/ioutil"
1110
"sync"
1211
)
1312

@@ -88,7 +87,7 @@ func (m *InmemSnapshotStore) Open(id string) (*SnapshotMeta, io.ReadCloser, erro
8887
// Make a copy of the contents, since a bytes.Buffer can only be read
8988
// once.
9089
contents := bytes.NewBuffer(m.latest.contents.Bytes())
91-
return &m.latest.meta, ioutil.NopCloser(contents), nil
90+
return &m.latest.meta, io.NopCloser(contents), nil
9291
}
9392

9493
// Write appends the given bytes to the snapshot contents

integ_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package raft
66
import (
77
"bytes"
88
"fmt"
9-
"io/ioutil"
109
"os"
1110
"sync/atomic"
1211
"testing"
@@ -77,7 +76,7 @@ func MakeRaft(t *testing.T, conf *Config, bootstrap bool) *RaftEnv {
7776
conf = inmemConfig(t)
7877
}
7978

80-
dir, err := ioutil.TempDir("", "raft")
79+
dir, err := os.MkdirTemp("", "raft")
8180
if err != nil {
8281
t.Fatalf("err: %v ", err)
8382
}

net_transport.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (n *NetworkTransport) getStreamContext() context.Context {
232232
return n.streamCtx
233233
}
234234

235-
// SetHeartbeatHandler is used to setup a heartbeat handler
235+
// SetHeartbeatHandler is used to set up a heartbeat handler
236236
// as a fast-pass. This is to avoid head-of-line blocking from
237237
// disk IO.
238238
func (n *NetworkTransport) SetHeartbeatHandler(cb func(rpc RPC)) {
@@ -367,7 +367,7 @@ func (n *NetworkTransport) returnConn(conn *netConn) {
367367
defer n.connPoolLock.Unlock()
368368

369369
key := conn.target
370-
conns, _ := n.connPool[key]
370+
conns := n.connPool[key]
371371

372372
if !n.IsShutdown() && len(conns) < n.maxPool {
373373
n.connPool[key] = append(conns, conn)
@@ -793,7 +793,7 @@ func (n *netPipeline) Consumer() <-chan AppendFuture {
793793
return n.doneCh
794794
}
795795

796-
// Closed is used to shutdown the pipeline connection.
796+
// Close is used to shut down the pipeline connection.
797797
func (n *netPipeline) Close() error {
798798
n.shutdownLock.Lock()
799799
defer n.shutdownLock.Unlock()

peersjson.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package raft
66
import (
77
"bytes"
88
"encoding/json"
9-
"io/ioutil"
9+
"os"
1010
)
1111

1212
// ReadPeersJSON consumes a legacy peers.json file in the format of the old JSON
@@ -17,7 +17,7 @@ import (
1717
// support for these, nor non-voter suffrage types.
1818
func ReadPeersJSON(path string) (Configuration, error) {
1919
// Read in the file.
20-
buf, err := ioutil.ReadFile(path)
20+
buf, err := os.ReadFile(path)
2121
if err != nil {
2222
return Configuration{}, err
2323
}
@@ -66,7 +66,7 @@ type configEntry struct {
6666
// versions that use server IDs.
6767
func ReadConfigJSON(path string) (Configuration, error) {
6868
// Read in the file.
69-
buf, err := ioutil.ReadFile(path)
69+
buf, err := os.ReadFile(path)
7070
if err != nil {
7171
return Configuration{}, err
7272
}

peersjson_test.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package raft
55

66
import (
7-
"io/ioutil"
87
"os"
98
"path/filepath"
109
"reflect"
@@ -15,14 +14,14 @@ import (
1514
func TestPeersJSON_BadConfiguration(t *testing.T) {
1615
var err error
1716
var base string
18-
base, err = ioutil.TempDir("", "")
17+
base, err = os.MkdirTemp("", "")
1918
if err != nil {
2019
t.Fatalf("err: %v", err)
2120
}
2221
defer os.RemoveAll(base)
2322

2423
peers := filepath.Join(base, "peers.json")
25-
if err = ioutil.WriteFile(peers, []byte("null"), 0666); err != nil {
24+
if err = os.WriteFile(peers, []byte("null"), 0666); err != nil {
2625
t.Fatalf("err: %v", err)
2726
}
2827

@@ -35,7 +34,7 @@ func TestPeersJSON_BadConfiguration(t *testing.T) {
3534
func TestPeersJSON_ReadPeersJSON(t *testing.T) {
3635
var err error
3736
var base string
38-
base, err = ioutil.TempDir("", "")
37+
base, err = os.MkdirTemp("", "")
3938
if err != nil {
4039
t.Fatalf("err: %v", err)
4140
}
@@ -47,7 +46,7 @@ func TestPeersJSON_ReadPeersJSON(t *testing.T) {
4746
"127.0.0.3:123"]
4847
`)
4948
peers := filepath.Join(base, "peers.json")
50-
if err = ioutil.WriteFile(peers, content, 0666); err != nil {
49+
if err = os.WriteFile(peers, content, 0666); err != nil {
5150
t.Fatalf("err: %v", err)
5251
}
5352
var configuration Configuration
@@ -83,7 +82,7 @@ func TestPeersJSON_ReadPeersJSON(t *testing.T) {
8382
func TestPeersJSON_ReadConfigJSON(t *testing.T) {
8483
var err error
8584
var base string
86-
base, err = ioutil.TempDir("", "")
85+
base, err = os.MkdirTemp("", "")
8786
if err != nil {
8887
t.Fatalf("err: %v", err)
8988
}
@@ -108,7 +107,7 @@ func TestPeersJSON_ReadConfigJSON(t *testing.T) {
108107
]
109108
`)
110109
peers := filepath.Join(base, "peers.json")
111-
if err = ioutil.WriteFile(peers, content, 0666); err != nil {
110+
if err = os.WriteFile(peers, content, 0666); err != nil {
112111
t.Fatalf("err: %v", err)
113112
}
114113

raft.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"container/list"
99
"fmt"
1010
"io"
11-
"io/ioutil"
1211
"sync/atomic"
1312
"time"
1413

@@ -217,7 +216,7 @@ func (r *Raft) runFollower() {
217216

218217
// Check if we have had a successful contact
219218
lastContact := r.LastContact()
220-
if time.Now().Sub(lastContact) < hbTimeout {
219+
if time.Since(lastContact) < hbTimeout {
221220
continue
222221
}
223222

@@ -1511,7 +1510,6 @@ func (r *Raft) appendEntries(rpc RPC, a *AppendEntriesRequest) {
15111510
// Everything went well, set success
15121511
resp.Success = true
15131512
r.setLastContact()
1514-
return
15151513
}
15161514

15171515
// processConfigurationLogEntry takes a log entry and updates the latest
@@ -1631,7 +1629,7 @@ func (r *Raft) requestVote(rpc RPC, req *RequestVoteRequest) {
16311629
// Check if we've voted in this election before
16321630
if lastVoteTerm == req.Term && lastVoteCandBytes != nil {
16331631
r.logger.Info("duplicate requestVote for same term", "term", req.Term)
1634-
if bytes.Compare(lastVoteCandBytes, candidateBytes) == 0 {
1632+
if bytes.Equal(lastVoteCandBytes, candidateBytes) {
16351633
r.logger.Warn("duplicate requestVote from", "candidate", candidate)
16361634
resp.Granted = true
16371635
}
@@ -1664,7 +1662,6 @@ func (r *Raft) requestVote(rpc RPC, req *RequestVoteRequest) {
16641662

16651663
resp.Granted = true
16661664
r.setLastContact()
1667-
return
16681665
}
16691666

16701667
// installSnapshot is invoked when we get a InstallSnapshot RPC call.
@@ -1680,7 +1677,7 @@ func (r *Raft) installSnapshot(rpc RPC, req *InstallSnapshotRequest) {
16801677
}
16811678
var rpcErr error
16821679
defer func() {
1683-
io.Copy(ioutil.Discard, rpc.Reader) // ensure we always consume all the snapshot data from the stream [see issue #212]
1680+
_, _ = io.Copy(io.Discard, rpc.Reader) // ensure we always consume all the snapshot data from the stream [see issue #212]
16841681
rpc.Respond(resp, rpcErr)
16851682
}()
16861683

0 commit comments

Comments
 (0)