fix: remove deprecated ioutil and rand calls

- Change ioutil to io and os calls per Go 1.16 deprecation
- Move global random to localized random source
This commit is contained in:
Tyler Davis
2023-02-21 20:19:36 +00:00
committed by Ben Johnson
parent 6bbced3d46
commit 91e57a6156
6 changed files with 15 additions and 19 deletions

5
db.go
View File

@@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"math/rand"
"os"
@@ -292,7 +291,7 @@ func (db *DB) invalidatePos(ctx context.Context) error {
}
defer rd.Close()
n, err := io.Copy(ioutil.Discard, lz4.NewReader(rd))
n, err := io.Copy(io.Discard, lz4.NewReader(rd))
if err != nil {
return err
}
@@ -671,7 +670,7 @@ func (db *DB) cleanGenerations(ctx context.Context) error {
}
dir := filepath.Join(db.MetaPath(), "generations")
fis, err := ioutil.ReadDir(dir)
fis, err := os.ReadDir(dir)
if os.IsNotExist(err) {
return nil
} else if err != nil {