refactor: replace ioutil=>io; update linter (#1211)

This commit is contained in:
Christopher Angelo Phillips
2022-09-16 17:58:16 +00:00
committed by GitHub
parent 0a1cd25ba5
commit b48316742f
11 changed files with 14 additions and 22 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ package file
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"regexp"
"text/template"
@@ -84,7 +84,7 @@ func (c Classifier) Classify(resolver source.FileResolver, location source.Locat
defer internal.CloseAndLogError(contentReader, location.VirtualPath)
// TODO: there is room for improvement here, as this may use an excessive amount of memory. Alternate approach is to leverage a RuneReader.
contents, err := ioutil.ReadAll(contentReader)
contents, err := io.ReadAll(contentReader)
if err != nil {
return nil, err
}
+1 -2
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"regexp"
"sort"
@@ -111,7 +110,7 @@ func extractValue(resolver source.FileResolver, location source.Location, start,
}
defer internal.CloseAndLogError(readCloser, location.VirtualPath)
n, err := io.CopyN(ioutil.Discard, readCloser, start)
n, err := io.CopyN(io.Discard, readCloser, start)
if err != nil {
return "", fmt.Errorf("unable to read contents for location=%q : %w", location, err)
}
+1 -2
View File
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"regexp"
"github.com/anchore/syft/internal"
@@ -79,7 +78,7 @@ func readerAtPosition(resolver source.FileResolver, location source.Location, se
return nil, fmt.Errorf("unable to fetch reader for location=%q : %w", location, err)
}
if seekPosition > 0 {
n, err := io.CopyN(ioutil.Discard, readCloser, seekPosition)
n, err := io.CopyN(io.Discard, readCloser, seekPosition)
if err != nil {
return nil, fmt.Errorf("unable to read contents for location=%q while searching for secrets: %w", location, err)
}