From bae126e713d9084276923cc8d9ed11315e5a1342 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Fri, 6 Jan 2023 13:08:58 -0500 Subject: [PATCH] Remove use of deprecated ioutil package --- archives/archives.go | 5 ++--- archives/archives_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/archives/archives.go b/archives/archives.go index 35bda2e..72128e5 100644 --- a/archives/archives.go +++ b/archives/archives.go @@ -9,7 +9,6 @@ import ( "encoding/hex" "fmt" "io" - "io/ioutil" "os" "path/filepath" "time" @@ -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) } @@ -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) } diff --git a/archives/archives_test.go b/archives/archives_test.go index 573f344..f294094 100644 --- a/archives/archives_test.go +++ b/archives/archives_test.go @@ -3,7 +3,7 @@ package archives import ( "compress/gzip" "context" - "io/ioutil" + "io" "os" "testing" "time" @@ -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") @@ -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)