Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

chore: remove refs to deprecated io/ioutil #93

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/scan.go
Expand Up @@ -18,7 +18,6 @@ Package cmd implements a simple command line interface using cobra
package cmd

import (
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -66,7 +65,7 @@ Scans a Go module directory. To scan the current directory recursively, use goka

// If remoteModule was set, clone the remote repository and scan it
if len(remoteModule) != 0 {
moduleTempDir, err := ioutil.TempDir(".", "gokart")
moduleTempDir, err := os.MkdirTemp(".", "gokart")
if err != nil {
log.Fatal("Error creating temporary directory: ", err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/scan_test.go
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"fmt"
"io/ioutil"
"io"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -65,7 +65,7 @@ func ExecuteCommand(cmd *cobra.Command, args []string) string {

// reset stdout to normal stdout and read output from cmd
w.Close()
stdoutres, _ := ioutil.ReadAll(r)
stdoutres, _ := io.ReadAll(r)
os.Stdout = old

//get the last line of output for comparison with our tests
Expand Down
5 changes: 2 additions & 3 deletions util/config.go
Expand Up @@ -17,7 +17,6 @@ package util
import (
_ "embed"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -80,7 +79,7 @@ var (
)

func LoadScanConfig() {
configBytes, err := ioutil.ReadFile(Config.YMLPath)
configBytes, err := os.ReadFile(Config.YMLPath)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -160,7 +159,7 @@ func getDefaultConfigPath() string {
// If ~/.gokart/analyzers.yml doesn't exist, create it with the default config
if _, err := os.Stat(yamlPath); os.IsNotExist(err) {
fmt.Printf("Initializing default config at %s\n", yamlPath)
if err := ioutil.WriteFile(yamlPath, DefaultAnalyzersContent, 0o744); err != nil {
if err := os.WriteFile(yamlPath, DefaultAnalyzersContent, 0o744); err != nil {
log.Fatalf("failed to write default config to %s: %v", yamlPath, err)
}
} else if err != nil {
Expand Down