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
@@ -4,7 +4,7 @@
// Package xcoff implements access to XCOFF (Extended Common Object File Format) files.
//nolint //this is an internal golang lib
//nolint:all
package xcoff
import (
@@ -7,7 +7,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//nolint // this is an internal golang lib
//nolint:all
package xcoff
// File Header.
@@ -3,7 +3,6 @@ package java
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
@@ -12,7 +11,7 @@ import (
func saveArchiveToTmp(archiveVirtualPath string, reader io.Reader) (string, string, func(), error) {
name := filepath.Base(archiveVirtualPath)
tempDir, err := ioutil.TempDir("", "syft-archive-contents-")
tempDir, err := os.MkdirTemp("", "syft-archive-contents-")
if err != nil {
return "", "", func() {}, fmt.Errorf("unable to create tempdir for archive processing: %w", err)
}
@@ -4,7 +4,7 @@ import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"path/filepath"
"github.com/anchore/syft/internal"
@@ -169,7 +169,7 @@ func (c *PackageCataloger) fetchDirectURLData(resolver source.FileResolver, meta
}
defer internal.CloseAndLogError(directURLContents, directURLLocation.VirtualPath)
buffer, err := ioutil.ReadAll(directURLContents)
buffer, err := io.ReadAll(directURLContents)
if err != nil {
return nil, nil, err
}
+1 -2
View File
@@ -3,7 +3,6 @@ package rpm
import (
"fmt"
"io"
"io/ioutil"
"os"
rpmdb "github.com/knqyf263/go-rpmdb/pkg"
@@ -17,7 +16,7 @@ import (
// parseRpmDb parses an "Packages" RPM DB and returns the Packages listed within it.
func parseRpmDB(resolver source.FilePathResolver, dbLocation source.Location, reader io.Reader) ([]pkg.Package, error) {
f, err := ioutil.TempFile("", internal.ApplicationName+"-rpmdb")
f, err := os.CreateTemp("", internal.ApplicationName+"-rpmdb")
if err != nil {
return nil, fmt.Errorf("failed to create temp rpmdb file: %w", err)
}
@@ -3,7 +3,6 @@ package swift
import (
"fmt"
"io"
"io/ioutil"
"strings"
"gopkg.in/yaml.v3"
@@ -18,7 +17,7 @@ var _ common.ParserFn = parsePodfileLock
// parsePodfileLock is a parser function for Podfile.lock contents, returning all cocoapods pods discovered.
func parsePodfileLock(_ string, reader io.Reader) ([]*pkg.Package, []artifact.Relationship, error) {
bytes, err := ioutil.ReadAll(reader)
bytes, err := io.ReadAll(reader)
if err != nil {
return nil, nil, fmt.Errorf("unable to read file: %w", err)
}