Merge pull request #2336 from argentpapa/master

multi: remove deprecated io/ioutil
This commit is contained in:
Oliver Gugger 2025-03-10 09:34:34 -06:00 committed by GitHub
commit 6afce8d608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 6 additions and 9 deletions

View file

@ -6,7 +6,7 @@ package main
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
@ -322,7 +322,7 @@ func createDefaultConfigFile(destinationPath, serverConfigPath string) error {
return err return err
} }
defer serverConfigFile.Close() defer serverConfigFile.Close()
content, err := ioutil.ReadAll(serverConfigFile) content, err := io.ReadAll(serverConfigFile)
if err != nil { if err != nil {
return err return err
} }

View file

@ -15,7 +15,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math" "math"
"net" "net"
"net/http" "net/http"
@ -852,7 +851,7 @@ func (c *Client) handleSendPostMessage(jReq *jsonRequest) {
} }
// Read the raw bytes and close the response. // Read the raw bytes and close the response.
respBytes, err := ioutil.ReadAll(httpResponse.Body) respBytes, err := io.ReadAll(httpResponse.Body)
httpResponse.Body.Close() httpResponse.Body.Close()
if err != nil { if err != nil {
err = fmt.Errorf("error reading json reply: %v", err) err = fmt.Errorf("error reading json reply: %v", err)

View file

@ -15,7 +15,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math/big" "math/big"
"math/rand" "math/rand"
"net" "net"
@ -4335,7 +4334,7 @@ func (s *rpcServer) jsonRPCRead(w http.ResponseWriter, r *http.Request, isAdmin
} }
// Read and close the JSON-RPC request body from the caller. // Read and close the JSON-RPC request body from the caller.
body, err := ioutil.ReadAll(r.Body) body, err := io.ReadAll(r.Body)
r.Body.Close() r.Body.Close()
if err != nil { if err != nil {
errCode := http.StatusBadRequest errCode := http.StatusBadRequest

View file

@ -9,7 +9,6 @@ import (
"compress/bzip2" "compress/bzip2"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net" "net"
"os" "os"
"testing" "testing"
@ -592,7 +591,7 @@ func BenchmarkDeserializeTxLarge(b *testing.B) {
b.Fatalf("Failed to read transaction data: %v", err) b.Fatalf("Failed to read transaction data: %v", err)
} }
defer fi.Close() defer fi.Close()
buf, err := ioutil.ReadAll(bzip2.NewReader(fi)) buf, err := io.ReadAll(bzip2.NewReader(fi))
if err != nil { if err != nil {
b.Fatalf("Failed to read transaction data: %v", err) b.Fatalf("Failed to read transaction data: %v", err)
} }
@ -713,7 +712,7 @@ func BenchmarkSerializeTxLarge(b *testing.B) {
b.Fatalf("Failed to read transaction data: %v", err) b.Fatalf("Failed to read transaction data: %v", err)
} }
defer fi.Close() defer fi.Close()
buf, err := ioutil.ReadAll(bzip2.NewReader(fi)) buf, err := io.ReadAll(bzip2.NewReader(fi))
if err != nil { if err != nil {
b.Fatalf("Failed to read transaction data: %v", err) b.Fatalf("Failed to read transaction data: %v", err)
} }