Stop using deprecated ioutil functions

This commit is contained in:
Katrina Verey
2022-08-10 16:59:18 -04:00
parent 416eed97c4
commit f6b72077c8
70 changed files with 322 additions and 362 deletions

View File

@@ -7,7 +7,7 @@ import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"strings"
@@ -130,7 +130,7 @@ func (c *Converter) readEmbeddedFile(name string) (string, error) {
return "", err
}
defer r.Close()
contents, err := ioutil.ReadAll(r)
contents, err := io.ReadAll(r)
if err != nil {
return "", err
}
@@ -139,7 +139,7 @@ func (c *Converter) readEmbeddedFile(name string) (string, error) {
}
func (c *Converter) readDiskFile(path string) (string, error) {
f, err := ioutil.ReadFile(path)
f, err := os.ReadFile(path)
if err != nil {
return "", err
}
@@ -159,7 +159,7 @@ func (c *Converter) mkDstDir() error {
func (c *Converter) write(m map[string]string) error {
for k, v := range m {
p := filepath.Join(c.outputDir, k)
err := ioutil.WriteFile(p, []byte(v), 0644)
err := os.WriteFile(p, []byte(v), 0644)
if err != nil {
return err
}

View File

@@ -5,7 +5,7 @@ package krmfunction
import (
"bytes"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"testing"
@@ -116,7 +116,7 @@ func TestTransformerConverter(t *testing.T) {
t.Skip("TODO: fix this test, which was not running in CI and does not pass")
dir := t.TempDir()
err := ioutil.WriteFile(filepath.Join(dir, "Plugin.go"),
err := os.WriteFile(filepath.Join(dir, "Plugin.go"),
getTransformerCode(), 0644)
require.NoError(t, err)
@@ -214,7 +214,7 @@ func TestGeneratorConverter(t *testing.T) {
t.Skip("TODO: fix this test, which was not running in CI and does not pass")
dir := t.TempDir()
err := ioutil.WriteFile(filepath.Join(dir, "Plugin.go"),
err := os.WriteFile(filepath.Join(dir, "Plugin.go"),
getGeneratorCode(), 0644)
require.NoError(t, err)