chore: update Go (#1469)

This commit is contained in:
Ludovic Fernandez 2021-08-25 11:44:11 +02:00 committed by GitHub
parent bc8ff4a192
commit dc2b19e1b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
98 changed files with 210 additions and 243 deletions

View file

@ -16,7 +16,7 @@ jobs:
strategy: strategy:
matrix: matrix:
go-version: [ 1.15, 1.16, 1.x ] go-version: [ 1.16, 1.17, 1.x ]
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
steps: steps:

View file

@ -14,8 +14,8 @@ jobs:
name: Main Process name: Main Process
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GO_VERSION: 1.16 GO_VERSION: 1.17
GOLANGCI_LINT_VERSION: v1.41.1 GOLANGCI_LINT_VERSION: v1.42.0
HUGO_VERSION: 0.54.0 HUGO_VERSION: 0.54.0
SEIHON_VERSION: v0.8.3 SEIHON_VERSION: v0.8.3
CGO_ENABLED: 0 CGO_ENABLED: 0

View file

@ -73,6 +73,7 @@
"noctx", "noctx",
"forcetypeassert", "forcetypeassert",
"tagliatelle", "tagliatelle",
"errname",
] ]
[issues] [issues]

View file

@ -4,7 +4,7 @@ import (
"crypto/x509" "crypto/x509"
"encoding/pem" "encoding/pem"
"errors" "errors"
"io/ioutil" "io"
"net/http" "net/http"
"github.com/go-acme/lego/v4/acme" "github.com/go-acme/lego/v4/acme"
@ -71,7 +71,7 @@ func (c *CertificateService) get(certURL string, bundle bool) (*acme.RawCertific
return nil, nil, err return nil, nil, err
} }
data, err := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize)) data, err := io.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
if err != nil { if err != nil {
return nil, resp.Header, err return nil, resp.Header, err
} }

View file

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"runtime" "runtime"
"strings" "strings"
@ -96,7 +95,7 @@ func (d *Doer) do(req *http.Request, response interface{}) (*http.Response, erro
} }
if response != nil { if response != nil {
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return resp, err return resp, err
} }
@ -120,7 +119,7 @@ func (d *Doer) formatUserAgent() string {
func checkError(req *http.Request, resp *http.Response) error { func checkError(req *http.Request, resp *http.Response) error {
if resp.StatusCode >= http.StatusBadRequest { if resp.StatusCode >= http.StatusBadRequest {
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("%d :: %s :: %s :: %w", resp.StatusCode, req.Method, req.URL, err) return fmt.Errorf("%d :: %s :: %s :: %w", resp.StatusCode, req.Method, req.URL, err)
} }

View file

@ -4,7 +4,7 @@ import (
"crypto/rand" "crypto/rand"
"crypto/rsa" "crypto/rsa"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"net/http" "net/http"
"testing" "testing"
@ -12,7 +12,7 @@ import (
"github.com/go-acme/lego/v4/platform/tester" "github.com/go-acme/lego/v4/platform/tester"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
jose "gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2"
) )
func TestOrderService_New(t *testing.T) { func TestOrderService_New(t *testing.T) {
@ -67,7 +67,7 @@ func TestOrderService_New(t *testing.T) {
} }
func readSignedBody(r *http.Request, privateKey *rsa.PrivateKey) ([]byte, error) { func readSignedBody(r *http.Request, privateKey *rsa.PrivateKey) ([]byte, error) {
reqBody, err := ioutil.ReadAll(r.Body) reqBody, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -7,7 +7,7 @@ import (
"encoding/base64" "encoding/base64"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"time" "time"
@ -465,7 +465,7 @@ func (c *Certifier) GetOCSP(bundle []byte) ([]byte, *ocsp.Response, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
issuerBytes, errC := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize)) issuerBytes, errC := io.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
if errC != nil { if errC != nil {
return nil, nil, errC return nil, nil, errC
} }
@ -494,7 +494,7 @@ func (c *Certifier) GetOCSP(bundle []byte) ([]byte, *ocsp.Response, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
ocspResBytes, err := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize)) ocspResBytes, err := io.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View file

@ -4,7 +4,7 @@ import (
"crypto/rand" "crypto/rand"
"crypto/rsa" "crypto/rsa"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/textproto" "net/textproto"
"testing" "testing"
@ -36,7 +36,7 @@ func TestChallenge(t *testing.T) {
t.Errorf("Get(%q) Content-Type: got %q, want %q", uri, resp.Header.Get("Content-Type"), want) t.Errorf("Get(%q) Content-Type: got %q, want %q", uri, resp.Header.Get("Content-Type"), want)
} }
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@ -283,7 +283,7 @@ func testServeWithProxy(t *testing.T, header, extra *testProxyHeader, expectErro
return fmt.Errorf("Get(%q) Content-Type: got %q, want %q", uri, resp.Header.Get("Content-Type"), want) return fmt.Errorf("Get(%q) Content-Type: got %q, want %q", uri, resp.Header.Get("Content-Type"), want)
} }
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -4,7 +4,7 @@ import (
"crypto/rand" "crypto/rand"
"crypto/rsa" "crypto/rsa"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"sort" "sort"
"testing" "testing"
@ -14,7 +14,7 @@ import (
"github.com/go-acme/lego/v4/platform/tester" "github.com/go-acme/lego/v4/platform/tester"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
jose "gopkg.in/square/go-jose.v2" "gopkg.in/square/go-jose.v2"
) )
func TestByType(t *testing.T) { func TestByType(t *testing.T) {
@ -154,7 +154,7 @@ func TestValidate(t *testing.T) {
// or if the JWS body is not the empty JSON payload "{}" or a POST-as-GET payload "" an error is returned. // or if the JWS body is not the empty JSON payload "{}" or a POST-as-GET payload "" an error is returned.
// We use this to verify challenge POSTs to the ts below do not send a JWS body. // We use this to verify challenge POSTs to the ts below do not send a JWS body.
func validateNoBody(privateKey *rsa.PrivateKey, r *http.Request) error { func validateNoBody(privateKey *rsa.PrivateKey, r *http.Request) error {
reqBody, err := ioutil.ReadAll(r.Body) reqBody, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -7,7 +7,6 @@ import (
"encoding/pem" "encoding/pem"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"net/url" "net/url"
"os" "os"
"path/filepath" "path/filepath"
@ -122,11 +121,11 @@ func (s *AccountsStorage) Save(account *Account) error {
return err return err
} }
return ioutil.WriteFile(s.accountFilePath, jsonBytes, filePerm) return os.WriteFile(s.accountFilePath, jsonBytes, filePerm)
} }
func (s *AccountsStorage) LoadAccount(privateKey crypto.PrivateKey) *Account { func (s *AccountsStorage) LoadAccount(privateKey crypto.PrivateKey) *Account {
fileBytes, err := ioutil.ReadFile(s.accountFilePath) fileBytes, err := os.ReadFile(s.accountFilePath)
if err != nil { if err != nil {
log.Fatalf("Could not load file for account %s: %v", s.userID, err) log.Fatalf("Could not load file for account %s: %v", s.userID, err)
} }
@ -207,7 +206,7 @@ func generatePrivateKey(file string, keyType certcrypto.KeyType) (crypto.Private
} }
func loadPrivateKey(file string) (crypto.PrivateKey, error) { func loadPrivateKey(file string) (crypto.PrivateKey, error) {
keyBytes, err := ioutil.ReadFile(file) keyBytes, err := os.ReadFile(file)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"crypto/x509" "crypto/x509"
"encoding/json" "encoding/json"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -144,7 +143,7 @@ func (s *CertificatesStorage) ExistsFile(domain, extension string) bool {
} }
func (s *CertificatesStorage) ReadFile(domain, extension string) ([]byte, error) { func (s *CertificatesStorage) ReadFile(domain, extension string) ([]byte, error) {
return ioutil.ReadFile(s.GetFileName(domain, extension)) return os.ReadFile(s.GetFileName(domain, extension))
} }
func (s *CertificatesStorage) GetFileName(domain, extension string) string { func (s *CertificatesStorage) GetFileName(domain, extension string) string {
@ -172,7 +171,7 @@ func (s *CertificatesStorage) WriteFile(domain, extension string, data []byte) e
filePath := filepath.Join(s.rootPath, baseFileName+extension) filePath := filepath.Join(s.rootPath, baseFileName+extension)
return ioutil.WriteFile(filePath, data, filePerm) return os.WriteFile(filePath, data, filePerm)
} }
func (s *CertificatesStorage) MoveToArchive(domain string) error { func (s *CertificatesStorage) MoveToArchive(domain string) error {

View file

@ -3,8 +3,8 @@ package cmd
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"net/url" "net/url"
"os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -66,7 +66,7 @@ func listCertificates(ctx *cli.Context) error {
continue continue
} }
data, err := ioutil.ReadFile(filename) data, err := os.ReadFile(filename)
if err != nil { if err != nil {
return err return err
} }
@ -110,7 +110,7 @@ func listAccount(ctx *cli.Context) error {
fmt.Println("Found the following accounts:") fmt.Println("Found the following accounts:")
for _, filename := range matches { for _, filename := range matches {
data, err := ioutil.ReadFile(filename) data, err := os.ReadFile(filename)
if err != nil { if err != nil {
return err return err
} }

View file

@ -4,7 +4,6 @@ import (
"crypto/x509" "crypto/x509"
"encoding/pem" "encoding/pem"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"strings" "strings"
"time" "time"
@ -98,7 +97,7 @@ func createNonExistingFolder(path string) error {
} }
func readCSRFile(filename string) (*x509.CertificateRequest, error) { func readCSRFile(filename string) (*x509.CertificateRequest, error) {
bytes, err := ioutil.ReadFile(filename) bytes, err := os.ReadFile(filename)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -6,7 +6,6 @@ import (
"crypto/rsa" "crypto/rsa"
"crypto/x509" "crypto/x509"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"testing" "testing"
@ -333,7 +332,7 @@ func TestChallengeTLS_Client_ObtainForCSR(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
user.registration = reg user.registration = reg
csrRaw, err := ioutil.ReadFile("./fixtures/csr.raw") csrRaw, err := os.ReadFile("./fixtures/csr.raw")
require.NoError(t, err) require.NoError(t, err)
csr, err := x509.ParseCertificateRequest(csrRaw) csr, err := x509.ParseCertificateRequest(csrRaw)

2
go.mod
View file

@ -1,6 +1,6 @@
module github.com/go-acme/lego/v4 module github.com/go-acme/lego/v4
go 1.15 go 1.16
// github.com/exoscale/egoscale v1.19.0 => It is an error, please don't use it. // github.com/exoscale/egoscale v1.19.0 => It is an error, please don't use it.
// github.com/linode/linodego v1.0.0 => It is an error, please don't use it. // github.com/linode/linodego v1.0.0 => It is an error, please don't use it.

2
go.sum
View file

@ -343,7 +343,6 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04 h1:o6uBwrhM5C8Ll3MAAxrQxRHEu7FkapwTuI2WmL1rw4g= github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04 h1:o6uBwrhM5C8Ll3MAAxrQxRHEu7FkapwTuI2WmL1rw4g=
github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04/go.mod h1:5sN+Lt1CaY4wsPvgQH/jsuJi4XO2ssZbdsIizr4CVC8= github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04/go.mod h1:5sN+Lt1CaY4wsPvgQH/jsuJi4XO2ssZbdsIizr4CVC8=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/nrdcg/auroradns v1.0.1 h1:m/kBq83Xvy3cU261MOknd8BdnOk12q4lAWM+kOdsC2Y= github.com/nrdcg/auroradns v1.0.1 h1:m/kBq83Xvy3cU261MOknd8BdnOk12q4lAWM+kOdsC2Y=
github.com/nrdcg/auroradns v1.0.1/go.mod h1:y4pc0i9QXYlFCWrhWrUSIETnZgrf4KuwjDIWmmXo3JI= github.com/nrdcg/auroradns v1.0.1/go.mod h1:y4pc0i9QXYlFCWrhWrUSIETnZgrf4KuwjDIWmmXo3JI=
@ -489,7 +488,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8= go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277 h1:d9qaMM+ODpCq+9We41//fu/sHsTnXcrqd1en3x+GKy4= go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277 h1:d9qaMM+ODpCq+9We41//fu/sHsTnXcrqd1en3x+GKy4=

View file

@ -9,7 +9,6 @@ import (
"fmt" "fmt"
"go/format" "go/format"
"io" "io"
"io/ioutil"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
@ -201,7 +200,7 @@ func generateReadMe(models *Providers) error {
return errors.New("missing end tag") return errors.New("missing end tag")
} }
return ioutil.WriteFile(readmePath, buffer.Bytes(), 0o666) return os.WriteFile(readmePath, buffer.Bytes(), 0o666)
} }
func extractTableData(models *Providers) (int, [][]string) { func extractTableData(models *Providers) (int, [][]string) {

View file

@ -7,7 +7,6 @@ import (
"go/format" "go/format"
"go/parser" "go/parser"
"go/token" "go/token"
"io/ioutil"
"log" "log"
"os" "os"
"regexp" "regexp"
@ -186,7 +185,7 @@ func writeUserAgentFile(filename, version, comment string) error {
return err return err
} }
return ioutil.WriteFile(filename, source, 0o644) return os.WriteFile(filename, source, 0o644)
} }
func bumpVersion(userAgent, mode string) (string, error) { func bumpVersion(userAgent, mode string) (string, error) {

View file

@ -4,7 +4,6 @@ import (
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"fmt" "fmt"
"io/ioutil"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -88,7 +87,7 @@ func createDefaultHTTPClient() *http.Client {
// caCertificatesEnvVar value then initCertPool will panic. // caCertificatesEnvVar value then initCertPool will panic.
func initCertPool() *x509.CertPool { func initCertPool() *x509.CertPool {
if customCACertsPath := os.Getenv(caCertificatesEnvVar); customCACertsPath != "" { if customCACertsPath := os.Getenv(caCertificatesEnvVar); customCACertsPath != "" {
customCAs, err := ioutil.ReadFile(customCACertsPath) customCAs, err := os.ReadFile(customCACertsPath)
if err != nil { if err != nil {
panic(fmt.Sprintf("error reading %s=%q: %v", panic(fmt.Sprintf("error reading %s=%q: %v",
caCertificatesEnvVar, customCACertsPath, err)) caCertificatesEnvVar, customCACertsPath, err))

View file

@ -3,7 +3,6 @@ package env
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"strconv" "strconv"
"strings" "strings"
@ -155,7 +154,7 @@ func GetOrFile(envVar string) string {
return envVarValue return envVarValue
} }
fileContents, err := ioutil.ReadFile(fileVarValue) fileContents, err := os.ReadFile(fileVarValue)
if err != nil { if err != nil {
log.Printf("Failed to read the file %s (defined by env var %s): %s", fileVarValue, fileVar, err) log.Printf("Failed to read the file %s (defined by env var %s): %s", fileVarValue, fileVar, err)
return "" return ""

View file

@ -313,7 +313,7 @@ func TestGetOrFile_ReadsFiles(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
defer os.Remove(file.Name()) defer os.Remove(file.Name())
err = ioutil.WriteFile(file.Name(), []byte("lego_file\n"), 0o644) err = os.WriteFile(file.Name(), []byte("lego_file\n"), 0o644)
require.NoError(t, err) require.NoError(t, err)
err = os.Setenv(varEnvFileName, file.Name()) err = os.Setenv(varEnvFileName, file.Name())
@ -340,7 +340,7 @@ func TestGetOrFile_PrefersEnvVars(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
defer os.Remove(file.Name()) defer os.Remove(file.Name())
err = ioutil.WriteFile(file.Name(), []byte("lego_file"), 0o644) err = os.WriteFile(file.Name(), []byte("lego_file"), 0o644)
require.NoError(t, err) require.NoError(t, err)
err = os.Setenv(varEnvFileName, file.Name()) err = os.Setenv(varEnvFileName, file.Name())

View file

@ -6,7 +6,7 @@ import (
"encoding/json" "encoding/json"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@ -82,11 +82,11 @@ func (c Client) Authentication(sessionLifetime int, sessionUpdateLifetime bool)
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
data, _ := ioutil.ReadAll(resp.Body) data, _ := io.ReadAll(resp.Body)
return "", fmt.Errorf("invalid status code: %d %s", resp.StatusCode, string(data)) return "", fmt.Errorf("invalid status code: %d %s", resp.StatusCode, string(data))
} }
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return "", fmt.Errorf("response read: %w", err) return "", fmt.Errorf("response read: %w", err)
} }
@ -206,11 +206,11 @@ func (c Client) do(credentialToken, action string, requestParams interface{}) (*
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
data, _ := ioutil.ReadAll(resp.Body) data, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("invalid status code: %d %s", resp.StatusCode, string(data)) return nil, fmt.Errorf("invalid status code: %d %s", resp.StatusCode, string(data))
} }
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("response read: %w", err) return nil, fmt.Errorf("response read: %w", err)
} }

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -70,7 +69,7 @@ func (c *Client) getRecords(domain, search string) ([]DNSRecord, error) {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err) return nil, fmt.Errorf("failed to read response body: %w", err)
} }
@ -113,7 +112,7 @@ func (c *Client) CreateRecord(domain string, record DNSRecord) (*DNSRecord, erro
return nil, err return nil, err
} }
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err) return nil, fmt.Errorf("failed to read response body: %w", err)
} }
@ -151,7 +150,7 @@ func (c *Client) DeleteRecord(domain, id string) error {
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
body, _ := ioutil.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
return fmt.Errorf("could not delete record %s; Domain: %s; Status: %s; Body: %s", id, domain, resp.Status, string(body)) return fmt.Errorf("could not delete record %s; Domain: %s; Status: %s; Body: %s", id, domain, resp.Status, string(body))
} }

View file

@ -2,7 +2,7 @@ package auroradns
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -163,7 +163,7 @@ func TestDNSProvider_Present(t *testing.T) {
assert.Equal(t, http.MethodPost, r.Method) assert.Equal(t, http.MethodPost, r.Method)
assert.Equal(t, "application/json", r.Header.Get("Content-Type"), "Content-Type") assert.Equal(t, "application/json", r.Header.Get("Content-Type"), "Content-Type")
reqBody, err := ioutil.ReadAll(r.Body) reqBody, err := io.ReadAll(r.Body)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, `{"type":"TXT","name":"_acme-challenge","content":"w6uP8Tcg6K2QR905Rms8iXTlksL6OD1KOWBxTK7wxPI","ttl":300}`, string(reqBody)) assert.Equal(t, `{"type":"TXT","name":"_acme-challenge","content":"w6uP8Tcg6K2QR905Rms8iXTlksL6OD1KOWBxTK7wxPI","ttl":300}`, string(reqBody))

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"path" "path"
"strconv" "strconv"
@ -132,7 +131,7 @@ func (d *DNSProvider) sendRequest(req *http.Request, result interface{}) error {
return nil return nil
} }
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@ -155,7 +154,7 @@ func checkResponse(resp *http.Response) error {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err)
} }

View file

@ -6,7 +6,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"time" "time"
@ -319,7 +319,7 @@ func getMetadata(config *Config, field string) (string, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body) respBody, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return "", err return "", err
} }

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
@ -139,7 +139,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
} }
defer resp.Body.Close() defer resp.Body.Close()
addTxtBytes, _ := ioutil.ReadAll(resp.Body) addTxtBytes, _ := io.ReadAll(resp.Body)
addTxtResp := string(addTxtBytes) addTxtResp := string(addTxtBytes)
// addEntity responds only with body text containing the ID of the created record // addEntity responds only with body text containing the ID of the created record
_, err = strconv.ParseUint(addTxtResp, 10, 64) _, err = strconv.ParseUint(addTxtResp, 10, 64)

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"regexp" "regexp"
"strconv" "strconv"
@ -41,7 +41,7 @@ func (d *DNSProvider) login() error {
} }
defer resp.Body.Close() defer resp.Body.Close()
authBytes, err := ioutil.ReadAll(resp.Body) authBytes, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("bluecat: %w", err) return fmt.Errorf("bluecat: %w", err)
} }
@ -74,7 +74,7 @@ func (d *DNSProvider) logout() error {
return fmt.Errorf("bluecat: request failed to delete session with HTTP status code %d", resp.StatusCode) return fmt.Errorf("bluecat: request failed to delete session with HTTP status code %d", resp.StatusCode)
} }
authBytes, err := ioutil.ReadAll(resp.Body) authBytes, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@ -240,7 +240,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{},
} }
if resp.StatusCode >= 400 { if resp.StatusCode >= 400 {
errBytes, _ := ioutil.ReadAll(resp.Body) errBytes, _ := io.ReadAll(resp.Body)
errResp := string(errBytes) errResp := string(errBytes)
return nil, fmt.Errorf("bluecat: request failed with HTTP status code %d\n Full message: %s", return nil, fmt.Errorf("bluecat: request failed with HTTP status code %d\n Full message: %s",
resp.StatusCode, errResp) resp.StatusCode, errResp)

View file

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@ -385,7 +384,7 @@ func (d *DNSProvider) sendRequest(req *http.Request, result interface{}) error {
return nil return nil
} }
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@ -408,7 +407,7 @@ func checkResponse(resp *http.Response) error {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err)
} }

View file

@ -3,7 +3,7 @@ package checkdomain
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
@ -99,7 +99,7 @@ func Test_createRecord(t *testing.T) {
return return
} }
content, err := ioutil.ReadAll(req.Body) content, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusBadRequest) http.Error(rw, err.Error(), http.StatusBadRequest)
return return

View file

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
) )
@ -235,7 +234,7 @@ func (c *Client) doRequest(req *http.Request) ([]byte, error) {
return nil, readError(req, resp) return nil, readError(req, resp)
} }
content, err := ioutil.ReadAll(resp.Body) content, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -243,7 +242,7 @@ func (c *Client) doRequest(req *http.Request) ([]byte, error) {
} }
func readError(req *http.Request, resp *http.Response) error { func readError(req *http.Request, resp *http.Response) error {
content, err := ioutil.ReadAll(resp.Body) content, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return errors.New(toUnreadableBodyMessage(req, content)) return errors.New(toUnreadableBodyMessage(req, content))
} }

View file

@ -4,7 +4,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -278,7 +278,7 @@ func (c *Client) doRequest(method string, uri *url.URL) (json.RawMessage, error)
defer resp.Body.Close() defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body) content, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, errors.New(toUnreadableBodyMessage(req, content)) return nil, errors.New(toUnreadableBodyMessage(req, content))
} }

View file

@ -7,7 +7,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@ -164,7 +164,7 @@ func (c *Client) doRequest(method, uri string, body []byte) (json.RawMessage, er
defer resp.Body.Close() defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body) content, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("CloudXNS: %s", toUnreadableBodyMessage(req, content)) return nil, fmt.Errorf("CloudXNS: %s", toUnreadableBodyMessage(req, content))
} }

View file

@ -3,7 +3,7 @@ package internal
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -267,7 +267,7 @@ func TestClientAddTxtRecord(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
assert.NotNil(t, req.Body) assert.NotNil(t, req.Body)
content, err := ioutil.ReadAll(req.Body) content, err := io.ReadAll(req.Body)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, test.expected, string(content)) assert.Equal(t, test.expected, string(content))

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
) )
@ -182,7 +182,7 @@ func (c *Client) do(method, path string, payload, result interface{}) error {
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
respBody, err := ioutil.ReadAll(resp.Body) respBody, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@ -192,7 +192,7 @@ func (c *Client) do(method, path string, payload, result interface{}) error {
} }
if result != nil { if result != nil {
respBody, err := ioutil.ReadAll(resp.Body) respBody, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -2,7 +2,7 @@ package internal
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -151,7 +151,7 @@ func TestClient_CreateRecord(t *testing.T) {
return return
} }
raw, err := ioutil.ReadAll(req.Body) raw, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusBadRequest) http.Error(rw, err.Error(), http.StatusBadRequest)
return return

View file

@ -3,7 +3,7 @@ package internal
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -63,7 +63,7 @@ func (c *Client) do(req *http.Request, v interface{}) error {
return err return err
} }
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("failed to read body: %w", err) return fmt.Errorf("failed to read body: %w", err)
} }
@ -94,7 +94,7 @@ func checkResponse(resp *http.Response) error {
return nil return nil
} }
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err == nil && data != nil { if err == nil && data != nil {
msg := &APIError{StatusCode: resp.StatusCode} msg := &APIError{StatusCode: resp.StatusCode}

View file

@ -3,7 +3,6 @@ package internal
import ( import (
"encoding/json" "encoding/json"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
"testing" "testing"
@ -42,7 +41,7 @@ func TestTxtRecordService_Create(t *testing.T) {
recordsJSON, err := json.Marshal(records) recordsJSON, err := json.Marshal(records)
require.NoError(t, err) require.NoError(t, err)
expectedContent, err := ioutil.ReadFile("./fixtures/records-Create.json") expectedContent, err := os.ReadFile("./fixtures/records-Create.json")
require.NoError(t, err) require.NoError(t, err)
assert.JSONEq(t, string(expectedContent), string(recordsJSON)) assert.JSONEq(t, string(expectedContent), string(recordsJSON))
@ -78,7 +77,7 @@ func TestTxtRecordService_GetAll(t *testing.T) {
recordsJSON, err := json.Marshal(records) recordsJSON, err := json.Marshal(records)
require.NoError(t, err) require.NoError(t, err)
expectedContent, err := ioutil.ReadFile("./fixtures/records-GetAll.json") expectedContent, err := os.ReadFile("./fixtures/records-GetAll.json")
require.NoError(t, err) require.NoError(t, err)
assert.JSONEq(t, string(expectedContent), string(recordsJSON)) assert.JSONEq(t, string(expectedContent), string(recordsJSON))
@ -211,7 +210,7 @@ func TestTxtRecordService_Search(t *testing.T) {
recordsJSON, err := json.Marshal(records) recordsJSON, err := json.Marshal(records)
require.NoError(t, err) require.NoError(t, err)
expectedContent, err := ioutil.ReadFile("./fixtures/records-Search.json") expectedContent, err := os.ReadFile("./fixtures/records-Search.json")
require.NoError(t, err) require.NoError(t, err)
assert.JSONEq(t, string(expectedContent), string(recordsJSON)) assert.JSONEq(t, string(expectedContent), string(recordsJSON))

View file

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"github.com/go-acme/lego/v4/challenge/dns01" "github.com/go-acme/lego/v4/challenge/dns01"
@ -85,7 +84,7 @@ func (d *DNSProvider) addTxtRecord(fqdn, value string) (*txtRecordResponse, erro
return nil, readError(req, resp) return nil, readError(req, resp)
} }
content, err := ioutil.ReadAll(resp.Body) content, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, errors.New(toUnreadableBodyMessage(req, content)) return nil, errors.New(toUnreadableBodyMessage(req, content))
} }
@ -113,7 +112,7 @@ func (d *DNSProvider) newRequest(method, reqURL string, body io.Reader) (*http.R
} }
func readError(req *http.Request, resp *http.Response) error { func readError(req *http.Request, resp *http.Response) error {
content, err := ioutil.ReadAll(resp.Body) content, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return errors.New(toUnreadableBodyMessage(req, content)) return errors.New(toUnreadableBodyMessage(req, content))
} }

View file

@ -2,7 +2,7 @@ package digitalocean
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -117,7 +117,7 @@ func TestDNSProvider_Present(t *testing.T) {
assert.Equal(t, "application/json", r.Header.Get("Content-Type"), "Content-Type") assert.Equal(t, "application/json", r.Header.Get("Content-Type"), "Content-Type")
assert.Equal(t, "Bearer asdf1234", r.Header.Get("Authorization"), "Authorization") assert.Equal(t, "Bearer asdf1234", r.Header.Get("Authorization"), "Authorization")
reqBody, err := ioutil.ReadAll(r.Body) reqBody, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
} }

View file

@ -8,7 +8,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"time" "time"
) )
@ -153,7 +153,7 @@ func (c *Client) sendRequest(method, resource string, payload interface{}) (*htt
} }
if resp.StatusCode > 299 { if resp.StatusCode > 299 {
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode) return nil, fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode)
} }

View file

@ -3,7 +3,7 @@ package dode
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/url" "net/url"
"github.com/go-acme/lego/v4/challenge/dns01" "github.com/go-acme/lego/v4/challenge/dns01"
@ -38,7 +38,7 @@ func (d *DNSProvider) updateTxtRecord(fqdn, token, txt string, clear bool) error
} }
defer response.Body.Close() defer response.Body.Close()
bodyBytes, err := ioutil.ReadAll(response.Body) bodyBytes, err := io.ReadAll(response.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"time" "time"
) )
@ -119,7 +119,7 @@ func (c *Client) doRequest(method string, endpoint string, reqBody []byte, v int
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode >= http.StatusBadRequest { if resp.StatusCode >= http.StatusBadRequest {
respBody, err := ioutil.ReadAll(resp.Body) respBody, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -3,7 +3,7 @@ package dreamhost
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/url" "net/url"
"github.com/go-acme/lego/v4/log" "github.com/go-acme/lego/v4/log"
@ -53,7 +53,7 @@ func (d *DNSProvider) updateTxtRecord(u fmt.Stringer) error {
return fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode) return fmt.Errorf("request failed with HTTP status code %d", resp.StatusCode)
} }
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("failed to read body: %w", err) return fmt.Errorf("failed to read body: %w", err)
} }

View file

@ -2,7 +2,7 @@ package duckdns
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
@ -35,7 +35,7 @@ func (d *DNSProvider) updateTxtRecord(domain, token, txt string, clear bool) err
} }
defer response.Body.Close() defer response.Body.Close()
bodyBytes, err := ioutil.ReadAll(response.Body) bodyBytes, err := io.ReadAll(response.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -164,7 +163,7 @@ func (c Client) doRetry(method, uri string, body []byte, data interface{}) error
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
all, err := ioutil.ReadAll(resp.Body) all, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("failed to read response body: %w", err) return fmt.Errorf("failed to read response body: %w", err)
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"path" "path"
) )
@ -81,7 +81,7 @@ func (d *DNSProvider) doRequest(method, resource string, requestMsg, responseMsg
defer response.Body.Close() defer response.Body.Close()
if response.StatusCode >= http.StatusBadRequest { if response.StatusCode >= http.StatusBadRequest {
body, err := ioutil.ReadAll(response.Body) body, err := io.ReadAll(response.Body)
if err != nil { if err != nil {
return fmt.Errorf("%d: failed to read response body: %w", response.StatusCode, err) return fmt.Errorf("%d: failed to read response body: %w", response.StatusCode, err)
} }

View file

@ -2,7 +2,7 @@ package easydns
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
@ -152,7 +152,7 @@ func TestDNSProvider_Present(t *testing.T) {
assert.Equal(t, "application/json", r.Header.Get("Content-Type"), "Content-Type") assert.Equal(t, "application/json", r.Header.Get("Content-Type"), "Content-Type")
assert.Equal(t, "Basic VE9LRU46U0VDUkVU", r.Header.Get("Authorization"), "Authorization") assert.Equal(t, "Basic VE9LRU46U0VDUkVU", r.Header.Get("Authorization"), "Authorization")
reqBody, err := ioutil.ReadAll(r.Body) reqBody, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
} }

View file

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
) )
// types for XML-RPC method calls and parameters // types for XML-RPC method calls and parameters
@ -314,7 +313,7 @@ func (d *DNSProvider) httpPost(url, bodyType string, body io.Reader) ([]byte, er
} }
defer resp.Body.Close() defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body) b, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("HTTP Post Error: %w", err) return nil, fmt.Errorf("HTTP Post Error: %w", err)
} }

View file

@ -2,7 +2,6 @@ package gandi
import ( import (
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"regexp" "regexp"
@ -128,7 +127,7 @@ func TestDNSProvider(t *testing.T) {
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, "text/xml", r.Header.Get("Content-Type"), "invalid content type") require.Equal(t, "text/xml", r.Header.Get("Content-Type"), "invalid content type")
req, errS := ioutil.ReadAll(r.Body) req, errS := io.ReadAll(r.Body)
require.NoError(t, errS) require.NoError(t, errS)
req = regexpDate.ReplaceAllLiteral(req, []byte(`[ACME Challenge 01 Jan 16 00:00 +0000]`)) req = regexpDate.ReplaceAllLiteral(req, []byte(`[ACME Challenge 01 Jan 16 00:00 +0000]`))

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"github.com/go-acme/lego/v4/log" "github.com/go-acme/lego/v4/log"
@ -191,7 +191,7 @@ func readBody(resp *http.Response) ([]byte, error) {
defer resp.Body.Close() defer resp.Body.Close()
rawBody, err := ioutil.ReadAll(resp.Body) rawBody, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -2,7 +2,7 @@ package gandiv5
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"regexp" "regexp"
@ -128,7 +128,7 @@ func TestDNSProvider(t *testing.T) {
return return
} }
body, errS := ioutil.ReadAll(req.Body) body, errS := io.ReadAll(req.Body)
if errS != nil { if errS != nil {
http.Error(rw, fmt.Sprintf(`{"message": "read body error: %v"}`, errS), http.StatusInternalServerError) http.Error(rw, fmt.Sprintf(`{"message": "read body error: %v"}`, errS), http.StatusInternalServerError)
return return

View file

@ -5,8 +5,8 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"net/http" "net/http"
"os"
"strconv" "strconv"
"time" "time"
@ -145,7 +145,7 @@ func NewDNSProviderServiceAccount(saFile string) (*DNSProvider, error) {
return nil, errors.New("googlecloud: Service Account file missing") return nil, errors.New("googlecloud: Service Account file missing")
} }
saKey, err := ioutil.ReadFile(saFile) saKey, err := os.ReadFile(saFile)
if err != nil { if err != nil {
return nil, fmt.Errorf("googlecloud: unable to read Service Account file: %w", err) return nil, fmt.Errorf("googlecloud: unable to read Service Account file: %w", err)
} }

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -142,7 +142,7 @@ func (c *Client) do(ctx context.Context, method, uri string, bodyParams interfac
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode/100 != 2 { if resp.StatusCode/100 != 2 {
all, _ := ioutil.ReadAll(resp.Body) all, _ := io.ReadAll(resp.Body)
e := APIError{ e := APIError{
StatusCode: resp.StatusCode, StatusCode: resp.StatusCode,

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"path" "path"
) )
@ -30,7 +29,7 @@ func (d *DNSProvider) getRecords(domainZone, rType, recordName string) ([]DNSRec
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
bodyBytes, _ := ioutil.ReadAll(resp.Body) bodyBytes, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("could not get records: Domain: %s; Record: %s, Status: %v; Body: %s", return nil, fmt.Errorf("could not get records: Domain: %s; Record: %s, Status: %v; Body: %s",
domainZone, recordName, resp.StatusCode, string(bodyBytes)) domainZone, recordName, resp.StatusCode, string(bodyBytes))
} }
@ -61,7 +60,7 @@ func (d *DNSProvider) updateTxtRecords(records []DNSRecord, domainZone, recordNa
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
bodyBytes, _ := ioutil.ReadAll(resp.Body) bodyBytes, _ := io.ReadAll(resp.Body)
return fmt.Errorf("could not create record %v; Status: %v; Body: %s", string(body), resp.StatusCode, string(bodyBytes)) return fmt.Errorf("could not create record %v; Status: %v; Body: %s", string(body), resp.StatusCode, string(bodyBytes))
} }

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -68,7 +67,7 @@ func (c *Client) getRecords(zoneID string) (*DNSRecords, error) {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
bodyBytes, _ := ioutil.ReadAll(resp.Body) bodyBytes, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("could not get records: zone ID: %s; Status: %s; Body: %s", return nil, fmt.Errorf("could not get records: zone ID: %s; Status: %s; Body: %s",
zoneID, resp.Status, string(bodyBytes)) zoneID, resp.Status, string(bodyBytes))
} }
@ -101,7 +100,7 @@ func (c *Client) CreateRecord(record DNSRecord) error {
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
bodyBytes, _ := ioutil.ReadAll(resp.Body) bodyBytes, _ := io.ReadAll(resp.Body)
return fmt.Errorf("could not create record %s; Status: %s; Body: %s", string(body), resp.Status, string(bodyBytes)) return fmt.Errorf("could not create record %s; Status: %s; Body: %s", string(body), resp.Status, string(bodyBytes))
} }

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"time" "time"
@ -105,7 +105,7 @@ func (d *DNSProvider) post(uri string, request, response interface{}) ([]byte, e
defer resp.Body.Close() defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body) content, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, errors.New(toUnreadableBodyMessage(uri, content)) return nil, errors.New(toUnreadableBodyMessage(uri, content))
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -198,7 +198,7 @@ func (c Client) do(req *http.Request) (json.RawMessage, error) {
switch resp.StatusCode { switch resp.StatusCode {
case http.StatusOK, http.StatusCreated: case http.StatusOK, http.StatusCreated:
all, err := ioutil.ReadAll(resp.Body) all, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("read response: %w", err) return nil, fmt.Errorf("read response: %w", err)
} }
@ -215,7 +215,7 @@ func (c Client) do(req *http.Request) (json.RawMessage, error) {
return nil, nil return nil, nil
default: default:
data, _ := ioutil.ReadAll(resp.Body) data, _ := io.ReadAll(resp.Body)
e := APIError{StatusCode: resp.StatusCode} e := APIError{StatusCode: resp.StatusCode}
err := json.Unmarshal(data, &e) err := json.Unmarshal(data, &e)

View file

@ -6,7 +6,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -196,7 +196,7 @@ func (d *DNSProvider) doPost(uri string, msg interface{}) error {
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode >= http.StatusBadRequest { if resp.StatusCode >= http.StatusBadRequest {
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("%d: failed to read response body: %w", resp.StatusCode, err) return fmt.Errorf("%d: failed to read response body: %w", resp.StatusCode, err)
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"log" "log"
"net/http" "net/http"
"net/url" "net/url"
@ -81,7 +81,7 @@ func (c *Client) UpdateTxtRecord(ctx context.Context, domain string, txt string)
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
bodyBytes, err := ioutil.ReadAll(resp.Body) bodyBytes, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -291,7 +290,7 @@ func (c *Client) do(req *http.Request, v interface{}) error {
return nil return nil
} }
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("failed to read body: %w", err) return fmt.Errorf("failed to read body: %w", err)
} }
@ -316,7 +315,7 @@ func checkResponse(resp *http.Response) error {
} }
// add response body to error message if not empty // add response body to error message if not empty
responseBody, _ := ioutil.ReadAll(resp.Body) responseBody, _ := io.ReadAll(resp.Body)
if len(responseBody) > 0 { if len(responseBody) > 0 {
msg = fmt.Sprintf("%s: %s", msg, string(responseBody)) msg = fmt.Sprintf("%s: %s", msg, string(responseBody))
} }

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
@ -186,7 +185,7 @@ type assertHandler func(http.ResponseWriter, *http.Request) (int, error)
func hasReqBody(v interface{}) assertHandler { func hasReqBody(v interface{}) assertHandler {
return func(rw http.ResponseWriter, req *http.Request) (int, error) { return func(rw http.ResponseWriter, req *http.Request) (int, error) {
reqBody, err := ioutil.ReadAll(req.Body) reqBody, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -143,7 +142,7 @@ func (c *Client) do(req *http.Request) (*APIResponse, error) {
defer func() { _ = rawResp.Body.Close() }() defer func() { _ = rawResp.Body.Close() }()
content, err := ioutil.ReadAll(rawResp.Body) content, err := io.ReadAll(rawResp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read the response body, status code: %d", rawResp.StatusCode) return nil, fmt.Errorf("failed to read the response body, status code: %d", rawResp.StatusCode)
} }

View file

@ -2,7 +2,7 @@ package internal
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -35,7 +35,7 @@ func TestClient_CreateDNSRecord(t *testing.T) {
return return
} }
raw, err := ioutil.ReadAll(req.Body) raw, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusBadRequest) http.Error(rw, err.Error(), http.StatusBadRequest)
return return

View file

@ -3,7 +3,7 @@ package rimuhosting
import ( import (
"encoding/xml" "encoding/xml"
"errors" "errors"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"regexp" "regexp"
@ -132,7 +132,7 @@ func (c Client) do(params, data interface{}) error {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
all, err := ioutil.ReadAll(resp.Body) all, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
) )
@ -149,7 +149,7 @@ func checkResponse(resp *http.Response) error {
return fmt.Errorf("request failed with status code %d and empty body", resp.StatusCode) return fmt.Errorf("request failed with status code %d and empty body", resp.StatusCode)
} }
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@ -168,7 +168,7 @@ func checkResponse(resp *http.Response) error {
} }
func unmarshalBody(resp *http.Response, to interface{}) error { func unmarshalBody(resp *http.Response, to interface{}) error {
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -3,9 +3,10 @@ package internal
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"os"
"path" "path"
"path/filepath" "path/filepath"
"strings" "strings"
@ -110,7 +111,7 @@ func (c Client) do(action string, params interface{}, response interface{}) erro
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode/100 != 2 { if resp.StatusCode/100 != 2 {
data, _ := ioutil.ReadAll(resp.Body) data, _ := io.ReadAll(resp.Body)
return fmt.Errorf("status code: %d, %s", resp.StatusCode, string(data)) return fmt.Errorf("status code: %d, %s", resp.StatusCode, string(data))
} }
@ -122,7 +123,7 @@ func (c Client) do(action string, params interface{}, response interface{}) erro
} }
func dump(endpoint *url.URL, resp *http.Response, response interface{}) error { func dump(endpoint *url.URL, resp *http.Response, response interface{}) error {
data, err := ioutil.ReadAll(resp.Body) data, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@ -131,7 +132,7 @@ func dump(endpoint *url.URL, resp *http.Response, response interface{}) error {
return !unicode.IsLetter(r) && !unicode.IsNumber(r) return !unicode.IsLetter(r) && !unicode.IsNumber(r)
}) })
err = ioutil.WriteFile(filepath.Join("fixtures", strings.Join(fields, "_")+".json"), data, 0o666) err = os.WriteFile(filepath.Join("fixtures", strings.Join(fields, "_")+".json"), data, 0o666)
if err != nil { if err != nil {
return err return err
} }

View file

@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -168,7 +167,7 @@ func (c *Client) makeRequest(ctx context.Context, method, uri string, body io.Re
} }
func readError(body io.Reader, statusCode int) error { func readError(body io.Reader, statusCode int) error {
bodyBytes, _ := ioutil.ReadAll(body) bodyBytes, _ := io.ReadAll(body)
cErr := &ClientError{StatusCode: statusCode} cErr := &ClientError{StatusCode: statusCode}

View file

@ -5,7 +5,7 @@ package dmapi
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -149,7 +149,7 @@ func (c *Client) postRequest(cmd string, data url.Values) (*Response, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -4,7 +4,7 @@ package svc
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
@ -59,7 +59,7 @@ func (c *Client) Send(zone, label, value string) error {
return err return err
} }
all, err := ioutil.ReadAll(resp.Body) all, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -2,7 +2,7 @@ package svc
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -20,7 +20,7 @@ func TestClient_Send(t *testing.T) {
return return
} }
all, _ := ioutil.ReadAll(req.Body) all, _ := io.ReadAll(req.Body)
if string(all) != "label=_acme-challenge&password=secret&type=TXT&username=test&value=123&zone=example.com" { if string(all) != "label=_acme-challenge&password=secret&type=TXT&username=test&value=123&zone=example.com" {
http.Error(rw, fmt.Sprintf("invalid request: %q", string(all)), http.StatusBadRequest) http.Error(rw, fmt.Sprintf("invalid request: %q", string(all)), http.StatusBadRequest)
@ -54,7 +54,7 @@ func TestClient_Send_empty(t *testing.T) {
return return
} }
all, _ := ioutil.ReadAll(req.Body) all, _ := io.ReadAll(req.Body)
if string(all) != "label=_acme-challenge&password=secret&type=TXT&username=test&value=&zone=example.com" { if string(all) != "label=_acme-challenge&password=secret&type=TXT&username=test&value=&zone=example.com" {
http.Error(rw, fmt.Sprintf("invalid request: %q", string(all)), http.StatusBadRequest) http.Error(rw, fmt.Sprintf("invalid request: %q", string(all)), http.StatusBadRequest)

View file

@ -2,7 +2,7 @@ package liquidweb
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -184,7 +184,7 @@ func TestDNSProvider_Present(t *testing.T) {
assert.Equal(t, "tacoman", password) assert.Equal(t, "tacoman", password)
assert.True(t, ok) assert.True(t, ok)
reqBody, err := ioutil.ReadAll(r.Body) reqBody, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return

View file

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"strings" "strings"
"time" "time"
@ -167,7 +166,7 @@ func (c *Client) httpPost(url string, bodyType string, body io.Reader) ([]byte,
return nil, fmt.Errorf("HTTP Post Error: %d", resp.StatusCode) return nil, fmt.Errorf("HTTP Post Error: %d", resp.StatusCode)
} }
b, err := ioutil.ReadAll(resp.Body) b, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("HTTP Post Error: %w", err) return nil, fmt.Errorf("HTTP Post Error: %w", err)
} }

View file

@ -3,7 +3,7 @@ package internal
import ( import (
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -210,7 +210,7 @@ func TestClient_GetZoneRecord(t *testing.T) {
func TestClient_rpcCall_404(t *testing.T) { func TestClient_rpcCall_404(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, err := ioutil.ReadAll(r.Body) _, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
@ -243,7 +243,7 @@ func TestClient_rpcCall_404(t *testing.T) {
func TestClient_rpcCall_RPCError(t *testing.T) { func TestClient_rpcCall_RPCError(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, err := ioutil.ReadAll(r.Body) _, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
@ -310,7 +310,7 @@ func createFakeServer(t *testing.T, serverResponses map[string]string) string {
return return
} }
req, err := ioutil.ReadAll(r.Body) req, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
) )
@ -42,7 +41,7 @@ func (d *Client) ListZones() ([]DNSZone, error) {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
bodyBytes, _ := ioutil.ReadAll(resp.Body) bodyBytes, _ := io.ReadAll(resp.Body)
var errResp errorResponse var errResp errorResponse
err = json.Unmarshal(bodyBytes, &errResp) err = json.Unmarshal(bodyBytes, &errResp)
@ -80,7 +79,7 @@ func (d *Client) CreateRecord(zone DNSZone, newRecord DNSRecord) (*DNSRecord, er
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
bodyBytes, _ := ioutil.ReadAll(resp.Body) bodyBytes, _ := io.ReadAll(resp.Body)
var errResp errorResponse var errResp errorResponse
err = json.Unmarshal(bodyBytes, &errResp) err = json.Unmarshal(bodyBytes, &errResp)
@ -120,7 +119,7 @@ func (d *Client) DeleteRecord(record *DNSRecord) error {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
bodyBytes, _ := ioutil.ReadAll(resp.Body) bodyBytes, _ := io.ReadAll(resp.Body)
var errResp errorResponse var errResp errorResponse
err = json.Unmarshal(bodyBytes, &errResp) err = json.Unmarshal(bodyBytes, &errResp)

View file

@ -2,7 +2,7 @@ package mydnsjp
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@ -23,7 +23,7 @@ func (d *DNSProvider) doRequest(domain, value, cmd string) error {
if resp.StatusCode >= 400 { if resp.StatusCode >= 400 {
var content []byte var content []byte
content, err = ioutil.ReadAll(resp.Body) content, err = io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"path" "path"
"strings" "strings"
@ -83,7 +83,7 @@ func (d *DNSProvider) login() error {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("login: %w", err) return fmt.Errorf("login: %w", err)
} }
@ -159,7 +159,7 @@ func (d *DNSProvider) createTXTRecord(zone, leaf, value string) error {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("createTXTRecord: %w", err) return fmt.Errorf("createTXTRecord: %w", err)
} }
@ -211,7 +211,7 @@ func (d *DNSProvider) removeTXTRecord(zone, leaf, value string) error {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("removeTXTRecord: %w", err) return fmt.Errorf("removeTXTRecord: %w", err)
} }

View file

@ -4,7 +4,7 @@ import (
"encoding/xml" "encoding/xml"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@ -180,7 +180,7 @@ func readBody(resp *http.Response) ([]byte, error) {
defer resp.Body.Close() defer resp.Body.Close()
rawBody, err := ioutil.ReadAll(resp.Body) rawBody, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -4,7 +4,7 @@ package namecheap
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@ -220,7 +220,7 @@ func getClientIP(client *http.Client, debug bool) (addr string, err error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
clientIP, err := ioutil.ReadAll(resp.Body) clientIP, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return "", err return "", err
} }

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"time" "time"
) )
@ -282,7 +282,7 @@ func checkResponse(resp *http.Response) error {
defer resp.Body.Close() defer resp.Body.Close()
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err)
} }
@ -300,7 +300,7 @@ func decodeResponseMsg(resp *http.Response) (*ResponseMsg, error) {
defer resp.Body.Close() defer resp.Body.Close()
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) return nil, fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err)
} }

View file

@ -2,7 +2,7 @@ package internal
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strconv" "strconv"
@ -141,7 +141,7 @@ func TestClient_Login(t *testing.T) {
defer tearDown() defer tearDown()
mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
raw, err := ioutil.ReadAll(req.Body) raw, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, err.Error(), http.StatusInternalServerError)
} }
@ -251,7 +251,7 @@ func TestClient_Logout(t *testing.T) {
defer tearDown() defer tearDown()
mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
raw, err := ioutil.ReadAll(req.Body) raw, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, err.Error(), http.StatusInternalServerError)
} }
@ -335,7 +335,7 @@ func TestClient_GetDNSRecords(t *testing.T) {
defer tearDown() defer tearDown()
mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
raw, err := ioutil.ReadAll(req.Body) raw, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, err.Error(), http.StatusInternalServerError)
} }
@ -443,7 +443,7 @@ func TestClient_GetDNSRecords_errors(t *testing.T) {
{ {
desc: "responsedata marshaling error", desc: "responsedata marshaling error",
handler: func(rw http.ResponseWriter, req *http.Request) { handler: func(rw http.ResponseWriter, req *http.Request) {
raw, err := ioutil.ReadAll(req.Body) raw, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, err.Error(), http.StatusInternalServerError)
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -51,7 +51,7 @@ func (c *Client) GetRecords(zoneID string) ([]DNSRecord, error) {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err) return nil, fmt.Errorf("failed to read response body: %w", err)
} }
@ -97,7 +97,7 @@ func (c *Client) CreateRecord(zoneID string, record DNSRecord) (*DNSRecord, erro
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err) return nil, fmt.Errorf("failed to read response body: %w", err)
} }
@ -137,7 +137,7 @@ func (c *Client) RemoveRecord(zoneID, recordID string) error {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("failed to read response body: %w", err) return fmt.Errorf("failed to read response body: %w", err)
} }

View file

@ -4,7 +4,6 @@ import (
"crypto/rsa" "crypto/rsa"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"github.com/go-acme/lego/v4/platform/config/env" "github.com/go-acme/lego/v4/platform/config/env"
@ -83,7 +82,7 @@ func getPrivateKey(envVar string) ([]byte, error) {
return nil, fmt.Errorf("no value provided for: %s or %s", envVar, fileVar) return nil, fmt.Errorf("no value provided for: %s or %s", envVar, fileVar)
} }
fileContents, err := ioutil.ReadFile(fileVarValue) fileContents, err := os.ReadFile(fileVarValue)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read the file %s (defined by env var %s): %w", fileVarValue, fileVar, err) return nil, fmt.Errorf("failed to read the file %s (defined by env var %s): %w", fileVarValue, fileVar, err)
} }

View file

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
) )
@ -258,7 +257,7 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{})
return nil, fmt.Errorf("OTC API request %s failed with HTTP status code %d", url, resp.StatusCode) return nil, fmt.Errorf("OTC API request %s failed with HTTP status code %d", url, resp.StatusCode)
} }
body1, err := ioutil.ReadAll(resp.Body) body1, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -2,7 +2,7 @@ package otc
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -147,7 +147,7 @@ func (m *DNSServerMock) HandleListRecordsetsSuccessfully() {
if r.Method == http.MethodPost { if r.Method == http.MethodPost {
assert.Equal(m.t, r.Header.Get("Content-Type"), "application/json") assert.Equal(m.t, r.Header.Get("Content-Type"), "application/json")
body, err := ioutil.ReadAll(r.Body) body, err := io.ReadAll(r.Body)
assert.Nil(m.t, err) assert.Nil(m.t, err)
exceptedString := `{ exceptedString := `{
"name": "_acme-challenge.example.com.", "name": "_acme-challenge.example.com.",

View file

@ -2,7 +2,7 @@ package rackspace
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strings" "strings"
@ -124,7 +124,7 @@ func startTestServers() (string, func()) {
func identityHandler(dnsEndpoint string) http.Handler { func identityHandler(dnsEndpoint string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
reqBody, err := ioutil.ReadAll(r.Body) reqBody, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return
@ -158,7 +158,7 @@ func dnsHandler() *http.ServeMux {
switch r.Method { switch r.Method {
// Used by `Present()` creating the TXT record // Used by `Present()` creating the TXT record
case http.MethodPost: case http.MethodPost:
reqBody, err := ioutil.ReadAll(r.Body) reqBody, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return

View file

@ -3,7 +3,7 @@ package internal
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
@ -102,7 +102,7 @@ func (c Client) do(request interface{}, fragments ...string) (*APIResponse, erro
return nil, fmt.Errorf("API error, status code: %d", resp.StatusCode) return nil, fmt.Errorf("API error, status code: %d", resp.StatusCode)
} }
all, err := ioutil.ReadAll(resp.Body) all, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
) )
@ -48,7 +48,7 @@ func (c *Client) GetRecords(domain string) ([]Record, error) {
return nil, fmt.Errorf("error: status code %d", resp.StatusCode) return nil, fmt.Errorf("error: status code %d", resp.StatusCode)
} }
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read body: %w", err) return nil, fmt.Errorf("failed to read body: %w", err)
} }
@ -80,7 +80,7 @@ func (c *Client) CreateUpdateRecord(domain string, data Record) (*Message, error
return nil, fmt.Errorf("error: status code %d", resp.StatusCode) return nil, fmt.Errorf("error: status code %d", resp.StatusCode)
} }
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read body: %w", err) return nil, fmt.Errorf("failed to read body: %w", err)
} }
@ -116,7 +116,7 @@ func (c *Client) DeleteRecord(domain string, data Record) (*Message, error) {
return nil, fmt.Errorf("error: status code %d", resp.StatusCode) return nil, fmt.Errorf("error: status code %d", resp.StatusCode)
} }
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read body: %w", err) return nil, fmt.Errorf("failed to read body: %w", err)
} }

View file

@ -3,7 +3,6 @@ package internal
import ( import (
"encoding/json" "encoding/json"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
@ -53,7 +52,7 @@ func TestClient_GetRecords(t *testing.T) {
recordsJSON, err := json.Marshal(records) recordsJSON, err := json.Marshal(records)
require.NoError(t, err) require.NoError(t, err)
expectedContent, err := ioutil.ReadFile("./fixtures/records-01.json") expectedContent, err := os.ReadFile("./fixtures/records-01.json")
require.NoError(t, err) require.NoError(t, err)
assert.JSONEq(t, string(expectedContent), string(recordsJSON)) assert.JSONEq(t, string(expectedContent), string(recordsJSON))
@ -92,7 +91,7 @@ func TestClient_CreateUpdateRecord(t *testing.T) {
return return
} }
content, err := ioutil.ReadAll(req.Body) content, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusBadRequest) http.Error(rw, err.Error(), http.StatusBadRequest)
return return
@ -163,7 +162,7 @@ func TestClient_DeleteRecord(t *testing.T) {
return return
} }
content, err := ioutil.ReadAll(req.Body) content, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusBadRequest) http.Error(rw, err.Error(), http.StatusBadRequest)
return return

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"time" "time"
) )
@ -81,7 +81,7 @@ func (c *Client) SetRecord(hostname string, value string, ttl int) error {
defer func() { _ = resp.Body.Close() }() defer func() { _ = resp.Body.Close() }()
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("failed to read response body: %w", err) return fmt.Errorf("failed to read response body: %w", err)
} }

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"path" "path"
@ -209,7 +209,7 @@ func readBody(resp *http.Response) ([]byte, error) {
defer resp.Body.Close() defer resp.Body.Close()
rawBody, err := ioutil.ReadAll(resp.Body) rawBody, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"path" "path"
) )
@ -99,7 +98,7 @@ func (d *DNSProvider) do(req *http.Request, result interface{}) error {
if resp.StatusCode >= http.StatusBadRequest { if resp.StatusCode >= http.StatusBadRequest {
var body []byte var body []byte
body, err = ioutil.ReadAll(resp.Body) body, err = io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("%d: failed to read response body: %w", resp.StatusCode, err) return fmt.Errorf("%d: failed to read response body: %w", resp.StatusCode, err)
} }
@ -113,7 +112,7 @@ func (d *DNSProvider) do(req *http.Request, result interface{}) error {
} }
if result != nil { if result != nil {
content, err := ioutil.ReadAll(resp.Body) content, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("request failed: %w", err) return fmt.Errorf("request failed: %w", err)
} }

View file

@ -2,9 +2,9 @@ package vinyldns
import ( import (
"fmt" "fmt"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os"
"sync" "sync"
"testing" "testing"
@ -102,7 +102,7 @@ func (h *mockRouter) add(method, path string, statusCode int, filename string) {
h.routes[method][path] = func(rw http.ResponseWriter, req *http.Request) { h.routes[method][path] = func(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(statusCode) rw.WriteHeader(statusCode)
data, err := ioutil.ReadFile(fmt.Sprintf("./fixtures/%s.json", filename)) data, err := os.ReadFile(fmt.Sprintf("./fixtures/%s.json", filename))
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, err.Error(), http.StatusInternalServerError)
return return

View file

@ -4,7 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@ -196,7 +196,7 @@ func (c *Client) do(ctx context.Context, command string, payload interface{}) (*
return nil, err return nil, err
} }
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -3,9 +3,9 @@ package internal
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os"
"regexp" "regexp"
"testing" "testing"
@ -38,7 +38,7 @@ func setupNew(t *testing.T, expectedForm string, filename string) *Client {
return return
} }
data, err := ioutil.ReadFile(fmt.Sprintf("./fixtures/%s.json", filename)) data, err := os.ReadFile(fmt.Sprintf("./fixtures/%s.json", filename))
if err != nil { if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError) http.Error(rw, err.Error(), http.StatusInternalServerError)
return return

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"path" "path"
) )
@ -100,7 +99,7 @@ func (d *DNSProvider) sendRequest(req *http.Request, result interface{}) error {
return nil return nil
} }
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@ -123,7 +122,7 @@ func checkResponse(resp *http.Response) error {
defer resp.Body.Close() defer resp.Body.Close()
raw, err := ioutil.ReadAll(resp.Body) raw, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err) return fmt.Errorf("unable to read body: status code=%d, error=%w", resp.StatusCode, err)
} }

View file

@ -4,7 +4,6 @@ package webroot
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -35,7 +34,7 @@ func (w *HTTPProvider) Present(domain, token, keyAuth string) error {
return fmt.Errorf("could not create required directories in webroot for HTTP challenge: %w", err) return fmt.Errorf("could not create required directories in webroot for HTTP challenge: %w", err)
} }
err = ioutil.WriteFile(challengeFilePath, []byte(keyAuth), 0o644) err = os.WriteFile(challengeFilePath, []byte(keyAuth), 0o644)
if err != nil { if err != nil {
return fmt.Errorf("could not write file in webroot for HTTP challenge: %w", err) return fmt.Errorf("could not write file in webroot for HTTP challenge: %w", err)
} }

View file

@ -1,7 +1,6 @@
package webroot package webroot
import ( import (
"io/ioutil"
"os" "os"
"testing" "testing"
@ -30,7 +29,7 @@ func TestHTTPProvider(t *testing.T) {
} }
var data []byte var data []byte
data, err = ioutil.ReadFile(challengeFilePath) data, err = os.ReadFile(challengeFilePath)
require.NoError(t, err) require.NoError(t, err)
dataStr := string(data) dataStr := string(data)