From 6ad71ac26ef41b372c2f0ca7839ec35e8f1a4235 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Thu, 31 Mar 2022 09:20:11 -0700 Subject: [PATCH] config: remove io/ioutil It's deprecated now. --- config.go | 5 ++--- config_test.go | 11 +++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/config.go b/config.go index 7c2c8b6..f6a4df3 100644 --- a/config.go +++ b/config.go @@ -34,7 +34,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" osuser "os/user" "path/filepath" @@ -279,7 +278,7 @@ func parseFile(filename string) (*Config, error) { } func parseWithDepth(filename string, depth uint8) (*Config, error) { - b, err := ioutil.ReadFile(filename) + b, err := os.ReadFile(filename) if err != nil { return nil, err } @@ -294,7 +293,7 @@ func isSystem(filename string) bool { // Decode reads r into a Config, or returns an error if r could not be parsed as // an SSH config file. func Decode(r io.Reader) (*Config, error) { - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(r) if err != nil { return nil, err } diff --git a/config_test.go b/config_test.go index f086600..2bdc3af 100644 --- a/config_test.go +++ b/config_test.go @@ -2,7 +2,6 @@ package ssh_config import ( "bytes" - "io/ioutil" "log" "os" "path/filepath" @@ -11,7 +10,7 @@ import ( ) func loadFile(t *testing.T, filename string) []byte { - data, err := ioutil.ReadFile(filename) + data, err := os.ReadFile(filename) if err != nil { t.Fatal(err) } @@ -267,7 +266,7 @@ func TestInclude(t *testing.T) { t.Skip("skipping fs write in short mode") } testPath := filepath.Join(homedir(), ".ssh", "kevinburke-ssh-config-test-file") - err := ioutil.WriteFile(testPath, includeFile, 0644) + err := os.WriteFile(testPath, includeFile, 0644) if err != nil { t.Skipf("couldn't write SSH config file: %v", err.Error()) } @@ -286,7 +285,7 @@ func TestIncludeSystem(t *testing.T) { t.Skip("skipping fs write in short mode") } testPath := filepath.Join("/", "etc", "ssh", "kevinburke-ssh-config-test-file") - err := ioutil.WriteFile(testPath, includeFile, 0644) + err := os.WriteFile(testPath, includeFile, 0644) if err != nil { t.Skipf("couldn't write SSH config file: %v", err.Error()) } @@ -310,7 +309,7 @@ func TestIncludeRecursive(t *testing.T) { t.Skip("skipping fs write in short mode") } testPath := filepath.Join(homedir(), ".ssh", "kevinburke-ssh-config-recursive-include") - err := ioutil.WriteFile(testPath, recursiveIncludeFile, 0644) + err := os.WriteFile(testPath, recursiveIncludeFile, 0644) if err != nil { t.Skipf("couldn't write SSH config file: %v", err.Error()) } @@ -331,7 +330,7 @@ func TestIncludeString(t *testing.T) { if testing.Short() { t.Skip("skipping fs write in short mode") } - data, err := ioutil.ReadFile("testdata/include") + data, err := os.ReadFile("testdata/include") if err != nil { log.Fatal(err) }