Skip to content

Commit c7a15f4

Browse files
committed
fix: remove ioutil deprecations
1 parent 8867fb1 commit c7a15f4

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

_examples/ssh-sftpserver/sftp.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76
"log"
87

98
"github.com/gliderlabs/ssh"
@@ -12,7 +11,7 @@ import (
1211

1312
// SftpHandler handler for SFTP subsystem
1413
func SftpHandler(sess ssh.Session) {
15-
debugStream := ioutil.Discard
14+
debugStream := io.Discard
1615
serverOptions := []sftp.ServerOption{
1716
sftp.WithDebug(debugStream),
1817
}

agent.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package ssh
22

33
import (
44
"io"
5-
"io/ioutil"
65
"net"
6+
"os"
77
"path"
88
"sync"
99

@@ -36,7 +36,7 @@ func AgentRequested(sess Session) bool {
3636
// NewAgentListener sets up a temporary Unix socket that can be communicated
3737
// to the session environment and used for forwarding connections.
3838
func NewAgentListener() (net.Listener, error) {
39-
dir, err := ioutil.TempDir("", agentTempDir)
39+
dir, err := os.MkdirTemp("", agentTempDir)
4040
if err != nil {
4141
return nil, err
4242
}

example_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package ssh_test
22

33
import (
44
"io"
5-
"io/ioutil"
5+
"os"
66

77
"github.com/gliderlabs/ssh"
88
)
@@ -28,7 +28,7 @@ func ExampleNoPty() {
2828
func ExamplePublicKeyAuth() {
2929
ssh.ListenAndServe(":2222", nil,
3030
ssh.PublicKeyAuth(func(ctx ssh.Context, key ssh.PublicKey) bool {
31-
data, _ := ioutil.ReadFile("/path/to/allowed/key.pub")
31+
data, _ := os.ReadFile("/path/to/allowed/key.pub")
3232
allowed, _, _, _, _ := ssh.ParseAuthorizedKey(data)
3333
return ssh.KeysEqual(key, allowed)
3434
}),

options.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package ssh
22

33
import (
4-
"io/ioutil"
4+
"os"
55

66
gossh "golang.org/x/crypto/ssh"
77
)
@@ -26,7 +26,7 @@ func PublicKeyAuth(fn PublicKeyHandler) Option {
2626
// from a PEM file at filepath.
2727
func HostKeyFile(filepath string) Option {
2828
return func(srv *Server) error {
29-
pemBytes, err := ioutil.ReadFile(filepath)
29+
pemBytes, err := os.ReadFile(filepath)
3030
if err != nil {
3131
return err
3232
}

tcpip_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package ssh
22

33
import (
44
"bytes"
5-
"io/ioutil"
5+
"io"
66
"net"
77
"strconv"
88
"strings"
@@ -58,7 +58,7 @@ func TestLocalPortForwardingWorks(t *testing.T) {
5858
if err != nil {
5959
t.Fatalf("Error connecting to %v: %v", l.Addr().String(), err)
6060
}
61-
result, err := ioutil.ReadAll(conn)
61+
result, err := io.ReadAll(conn)
6262
if err != nil {
6363
t.Fatal(err)
6464
}

0 commit comments

Comments
 (0)