Skip to content

Commit

Permalink
Remove use of deprecated ioutil package
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jan 6, 2023
1 parent f16a03a commit bae126e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions archives/archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -346,7 +345,7 @@ func BuildRollupArchive(ctx context.Context, db *sqlx.DB, conf *Config, s3Client

// great, we have all the dailies we need, download them
filename := fmt.Sprintf("%s_%d_%s_%d_%02d_", monthlyArchive.ArchiveType, monthlyArchive.Org.ID, monthlyArchive.Period, monthlyArchive.StartDate.Year(), monthlyArchive.StartDate.Month())
file, err := ioutil.TempFile(conf.TempDir, filename)
file, err := os.CreateTemp(conf.TempDir, filename)
if err != nil {
return errors.Wrapf(err, "error creating temp file: %s", filename)
}
Expand Down Expand Up @@ -479,7 +478,7 @@ func CreateArchiveFile(ctx context.Context, db *sqlx.DB, archive *Archive, archi
})

filename := fmt.Sprintf("%s_%d_%s%d%02d%02d_", archive.ArchiveType, archive.Org.ID, archive.Period, archive.StartDate.Year(), archive.StartDate.Month(), archive.StartDate.Day())
file, err := ioutil.TempFile(archivePath, filename)
file, err := os.CreateTemp(archivePath, filename)
if err != nil {
return errors.Wrapf(err, "error creating temp file: %s", filename)
}
Expand Down
8 changes: 4 additions & 4 deletions archives/archives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package archives
import (
"compress/gzip"
"context"
"io/ioutil"
"io"
"os"
"testing"
"time"
Expand All @@ -18,7 +18,7 @@ import (
)

func setup(t *testing.T) *sqlx.DB {
testDB, err := ioutil.ReadFile("../testdb.sql")
testDB, err := os.ReadFile("../testdb.sql")
assert.NoError(t, err)

db, err := sqlx.Open("postgres", "postgres://temba:temba@localhost:5432/archiver_test?sslmode=disable&TimeZone=UTC")
Expand Down Expand Up @@ -180,10 +180,10 @@ func assertArchiveFile(t *testing.T, archive *Archive, truthName string) {

zTestReader, err := gzip.NewReader(testFile)
assert.NoError(t, err)
test, err := ioutil.ReadAll(zTestReader)
test, err := io.ReadAll(zTestReader)
assert.NoError(t, err)

truth, err := ioutil.ReadFile("./testdata/" + truthName)
truth, err := os.ReadFile("./testdata/" + truthName)
assert.NoError(t, err)

assert.Equal(t, truth, test)
Expand Down

0 comments on commit bae126e

Please sign in to comment.