Skip to content

Commit

Permalink
lint: Remove usage of deprecated io/util package
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed May 25, 2023
1 parent bfb3f5b commit 4518746
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
23 changes: 11 additions & 12 deletions extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -187,9 +186,9 @@ func TestArchiveFailure(t *testing.T) {

func TestExtract(t *testing.T) {
for _, test := range ExtractCases {
dir, _ := ioutil.TempDir("", "")
dir, _ := os.MkdirTemp("", "")
dir = filepath.Join(dir, "test")
data, err := ioutil.ReadFile(test.Archive)
data, err := os.ReadFile(test.Archive)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -222,8 +221,8 @@ func TestExtract(t *testing.T) {
}

func BenchmarkArchive(b *testing.B) {
dir, _ := ioutil.TempDir("", "")
data, _ := ioutil.ReadFile("testdata/archive.tar.bz2")
dir, _ := os.MkdirTemp("", "")
data, _ := os.ReadFile("testdata/archive.tar.bz2")

b.StartTimer()

Expand All @@ -244,8 +243,8 @@ func BenchmarkArchive(b *testing.B) {
}

func BenchmarkTarBz2(b *testing.B) {
dir, _ := ioutil.TempDir("", "")
data, _ := ioutil.ReadFile("testdata/archive.tar.bz2")
dir, _ := os.MkdirTemp("", "")
data, _ := os.ReadFile("testdata/archive.tar.bz2")

b.StartTimer()

Expand All @@ -266,8 +265,8 @@ func BenchmarkTarBz2(b *testing.B) {
}

func BenchmarkTarGz(b *testing.B) {
dir, _ := ioutil.TempDir("", "")
data, _ := ioutil.ReadFile("testdata/archive.tar.gz")
dir, _ := os.MkdirTemp("", "")
data, _ := os.ReadFile("testdata/archive.tar.gz")

b.StartTimer()

Expand All @@ -288,8 +287,8 @@ func BenchmarkTarGz(b *testing.B) {
}

func BenchmarkZip(b *testing.B) {
dir, _ := ioutil.TempDir("", "")
data, _ := ioutil.ReadFile("testdata/archive.zip")
dir, _ := os.MkdirTemp("", "")
data, _ := os.ReadFile("testdata/archive.zip")

b.StartTimer()

Expand Down Expand Up @@ -319,7 +318,7 @@ func testWalk(t *testing.T, dir string, testFiles Files) {
} else if info.Mode()&os.ModeSymlink != 0 {
files[path] = "link"
} else {
data, err := ioutil.ReadFile(filepath.Join(dir, path))
data, err := os.ReadFile(filepath.Join(dir, path))
require.NoError(t, err)
files[path] = strings.TrimSpace(string(data))
}
Expand Down
3 changes: 1 addition & 2 deletions extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -307,7 +306,7 @@ func (e *Extractor) Zip(ctx context.Context, body io.Reader, location string, re
case info.Mode()&os.ModeSymlink != 0:
if f, err := header.Open(); err != nil {
return errors.Annotatef(err, "Open link %s", path)
} else if name, err := ioutil.ReadAll(f); err != nil {
} else if name, err := io.ReadAll(f); err != nil {
return errors.Annotatef(err, "Read address of link %s", path)
} else {
links = append(links, link{Path: path, Name: string(name)})
Expand Down

0 comments on commit 4518746

Please sign in to comment.