config: remove io/ioutil

It's deprecated now.
This commit is contained in:
Kevin Burke
2022-03-31 09:26:24 -07:00
parent 0970dd2cc4
commit 6ad71ac26e
2 changed files with 7 additions and 9 deletions
+2 -3
View File
@@ -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
}
+5 -6
View File
@@ -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)
}