Skip to content

Commit 9d34a1e

Browse files
committed
refactor: use os.ReadDir for lightweight directory reading
`os.ReadDir` was added in Go 1.16 as part of the deprecation of `ioutil` package. It is a more efficient implementation than `ioutil.ReadDir` as stated here https://pkg.go.dev/io/ioutil#ReadDir. Signed-off-by: Eng Zer Jun <[email protected]>
1 parent 216ff7c commit 9d34a1e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

internal/raft/file_snapshot.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"hash"
99
"hash/crc64"
1010
"io"
11-
"io/ioutil"
1211
"log"
1312
"os"
1413
"path/filepath"
@@ -214,7 +213,7 @@ func (f *FileSnapshotStore) List() ([]*SnapshotMeta, error) {
214213
// getSnapshots returns all the known snapshots.
215214
func (f *FileSnapshotStore) getSnapshots() ([]*fileSnapshotMeta, error) {
216215
// Get the eligible snapshots
217-
snapshots, err := ioutil.ReadDir(f.path)
216+
snapshots, err := os.ReadDir(f.path)
218217
if err != nil {
219218
f.logger.Printf("[ERR] snapshot: Failed to scan snapshot dir: %v", err)
220219
return nil, err

0 commit comments

Comments
 (0)