Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove use of deprecated ioutil package #246

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -128,7 +127,7 @@ func (c *Config) RemoveRule(i int) {
}

func loadConfig(filename string) (c Config, err error) {
yamlFile, err := ioutil.ReadFile(filename)
yamlFile, err := os.ReadFile(filename)
log.Debug().Str("filename", filename).Msg("Adding custom ruleset from")
if err != nil {
return c, err
Expand Down
3 changes: 1 addition & 2 deletions pkg/parser/findings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package parser

import (
"go/token"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -101,7 +100,7 @@ func newFile(t *testing.T, text string) (*os.File, error) {
// newFile creates a new file with the prefix defined for testing.
// The file, and the directory that the file was created in will be removed at the completion of the test
func newFileWithPrefix(t *testing.T, prefix, text string) (*os.File, error) {
tmpFile, err := ioutil.TempFile(os.TempDir(), prefix)
tmpFile, err := os.CreateTemp(os.TempDir(), prefix)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package parser

import (
"go/token"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -284,7 +283,7 @@ func TestParser_ParsePaths(t *testing.T) {
}

func writeToStdin(t *testing.T, text string, f func()) error {
tmpfile, err := ioutil.TempFile(os.TempDir(), "")
tmpfile, err := os.CreateTemp(os.TempDir(), "")
if err != nil {
return err
}
Expand All @@ -310,7 +309,7 @@ func writeToStdin(t *testing.T, text string, f func()) error {

func BenchmarkParsePaths(b *testing.B) {
zerolog.SetGlobalLevel(zerolog.NoLevel)
tmpFile, err := ioutil.TempFile(b.TempDir(), "")
tmpFile, err := os.CreateTemp(b.TempDir(), "")
assert.NoError(b, err)

for i := 0; i < 100; i++ {
Expand Down
3 changes: 1 addition & 2 deletions pkg/walker/walker_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package walker

import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand All @@ -11,7 +10,7 @@ import (
)

func TestWalker_Walk(t *testing.T) {
dir, err := ioutil.TempDir(os.TempDir(), "")
dir, err := os.MkdirTemp(os.TempDir(), "")
assert.NoError(t, err)
defer os.RemoveAll(dir)
assert.DirExists(t, dir)
Expand Down