From 9c07f4f512f71799a796cb3cdb5532657df8444f Mon Sep 17 00:00:00 2001 From: Marwan Sulaiman Date: Wed, 23 Aug 2023 16:42:44 +0100 Subject: [PATCH] all: replace deprecated ioutil references This PR removes calls to ioutil library and replaces them with their new locations in the io and os packages. Fixes #9034 Updates #5210 Signed-off-by: Marwan Sulaiman --- cmd/ssh-auth-none-demo/ssh-auth-none-demo.go | 3 +-- ipn/localapi/localapi.go | 9 ++++----- ssh/tailssh/tailssh_test.go | 3 +-- tsnet/tsnet_test.go | 3 +-- tstest/iosdeps/iosdeps.go | 1 - 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cmd/ssh-auth-none-demo/ssh-auth-none-demo.go b/cmd/ssh-auth-none-demo/ssh-auth-none-demo.go index 82b436d5c..ee929299a 100644 --- a/cmd/ssh-auth-none-demo/ssh-auth-none-demo.go +++ b/cmd/ssh-auth-none-demo/ssh-auth-none-demo.go @@ -19,7 +19,6 @@ "flag" "fmt" "io" - "io/ioutil" "log" "os" "path/filepath" @@ -149,7 +148,7 @@ func getHostKeys(dir string) (ret []ssh.Signer, err error) { func hostKeyFileOrCreate(keyDir, typ string) ([]byte, error) { path := filepath.Join(keyDir, "ssh_host_"+typ+"_key") - v, err := ioutil.ReadFile(path) + v, err := os.ReadFile(path) if err == nil { return v, nil } diff --git a/ipn/localapi/localapi.go b/ipn/localapi/localapi.go index d16649a06..44ec4dc43 100644 --- a/ipn/localapi/localapi.go +++ b/ipn/localapi/localapi.go @@ -13,7 +13,6 @@ "errors" "fmt" "io" - "io/ioutil" "net" "net/http" "net/http/httputil" @@ -1708,7 +1707,7 @@ func (h *Handler) serveTKADisable(w http.ResponseWriter, r *http.Request) { } body := io.LimitReader(r.Body, 1024*1024) - secret, err := ioutil.ReadAll(body) + secret, err := io.ReadAll(body) if err != nil { http.Error(w, "reading secret", 400) return @@ -1781,7 +1780,7 @@ func (h *Handler) serveTKAAffectedSigs(w http.ResponseWriter, r *http.Request) { http.Error(w, "use POST", http.StatusMethodNotAllowed) return } - keyID, err := ioutil.ReadAll(http.MaxBytesReader(w, r.Body, 2048)) + keyID, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 2048)) if err != nil { http.Error(w, "reading body", http.StatusBadRequest) return @@ -1850,7 +1849,7 @@ func (h *Handler) serveTKACosignRecoveryAUM(w http.ResponseWriter, r *http.Reque } body := io.LimitReader(r.Body, 1024*1024) - aumBytes, err := ioutil.ReadAll(body) + aumBytes, err := io.ReadAll(body) if err != nil { http.Error(w, "reading AUM", http.StatusBadRequest) return @@ -1881,7 +1880,7 @@ func (h *Handler) serveTKASubmitRecoveryAUM(w http.ResponseWriter, r *http.Reque } body := io.LimitReader(r.Body, 1024*1024) - aumBytes, err := ioutil.ReadAll(body) + aumBytes, err := io.ReadAll(body) if err != nil { http.Error(w, "reading AUM", http.StatusBadRequest) return diff --git a/ssh/tailssh/tailssh_test.go b/ssh/tailssh/tailssh_test.go index 625001885..8d6b8110c 100644 --- a/ssh/tailssh/tailssh_test.go +++ b/ssh/tailssh/tailssh_test.go @@ -15,7 +15,6 @@ "errors" "fmt" "io" - "io/ioutil" "net" "net/http" "net/http/httptest" @@ -562,7 +561,7 @@ func TestSSHRecordingNonInteractive(t *testing.T) { recordingServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer cancel() var err error - recording, err = ioutil.ReadAll(r.Body) + recording, err = io.ReadAll(r.Body) if err != nil { t.Error(err) return diff --git a/tsnet/tsnet_test.go b/tsnet/tsnet_test.go index 7053e811a..0c215ee5b 100644 --- a/tsnet/tsnet_test.go +++ b/tsnet/tsnet_test.go @@ -16,7 +16,6 @@ "flag" "fmt" "io" - "io/ioutil" "math/big" "net" "net/http" @@ -523,7 +522,7 @@ func TestFunnel(t *testing.T) { t.Errorf("unexpected status code: %v", resp.StatusCode) return } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { t.Fatal(err) } diff --git a/tstest/iosdeps/iosdeps.go b/tstest/iosdeps/iosdeps.go index 07e45d0e5..80772a6b6 100644 --- a/tstest/iosdeps/iosdeps.go +++ b/tstest/iosdeps/iosdeps.go @@ -17,7 +17,6 @@ _ "fmt" _ "io" _ "io/fs" - _ "io/ioutil" _ "log" _ "math" _ "net"