diff --git a/build/generate/featureMatrix.go b/build/generate/featureMatrix.go index c27926095..f6d140fd2 100644 --- a/build/generate/featureMatrix.go +++ b/build/generate/featureMatrix.go @@ -3,7 +3,7 @@ package main import ( "bytes" "html/template" - "io/ioutil" + "os" "sort" "github.com/StackExchange/dnscontrol/v3/providers" @@ -109,7 +109,7 @@ func generateFeatureMatrix() error { if err != nil { return err } - return ioutil.WriteFile("docs/_includes/matrix.html", buf.Bytes(), 0644) + return os.WriteFile("docs/_includes/matrix.html", buf.Bytes(), 0644) } // FeatureDef describes features. diff --git a/commands/fmt.go b/commands/fmt.go index ba1c54561..6a3c7b3a7 100644 --- a/commands/fmt.go +++ b/commands/fmt.go @@ -2,7 +2,6 @@ package commands import ( "fmt" - "io/ioutil" "os" "github.com/ditashi/jsbeautifier-go/jsbeautifier" @@ -47,7 +46,7 @@ func (args *FmtArgs) flags() []cli.Flag { // FmtFile reads and formats a file. func FmtFile(args FmtArgs) error { - fileBytes, readErr := ioutil.ReadFile(args.InputFile) + fileBytes, readErr := os.ReadFile(args.InputFile) if readErr != nil { return readErr } @@ -67,7 +66,7 @@ func FmtFile(args FmtArgs) error { if args.OutputFile == "" { fmt.Print(beautified) } else { - if err := ioutil.WriteFile(args.OutputFile, []byte(beautified), 0744); err != nil { + if err := os.WriteFile(args.OutputFile, []byte(beautified), 0744); err != nil { return err } fmt.Fprintf(os.Stderr, "File %s successfully written\n", args.OutputFile) diff --git a/commands/gz_test.go b/commands/gz_test.go index 8f344bb3d..11d00654a 100644 --- a/commands/gz_test.go +++ b/commands/gz_test.go @@ -2,7 +2,6 @@ package commands import ( "fmt" - "io/ioutil" "log" "os" "testing" @@ -33,7 +32,7 @@ func testFormat(t *testing.T, domain, format string) { expectedFilename := fmt.Sprintf("test_data/%s.zone.%s", domain, format) outputFiletmpl := fmt.Sprintf("%s.zone.%s.*.txt", domain, format) - outfile, err := ioutil.TempFile("", outputFiletmpl) + outfile, err := os.CreateTemp("", outputFiletmpl) if err != nil { log.Fatal(fmt.Errorf("gz can't TempFile %q: %w", outputFiletmpl, err)) } @@ -56,19 +55,19 @@ func testFormat(t *testing.T, domain, format string) { } // Read the actual result: - got, err := ioutil.ReadFile(outfile.Name()) + got, err := os.ReadFile(outfile.Name()) if err != nil { log.Fatal(fmt.Errorf("can't read actuals %q: %w", outfile.Name(), err)) } // Read the expected result - want, err := ioutil.ReadFile(expectedFilename) + want, err := os.ReadFile(expectedFilename) if err != nil { log.Fatal(fmt.Errorf("can't read expected %q: %w", outfile.Name(), err)) } // // Update got -> want - // err = ioutil.WriteFile(expectedFilename, got, 0644) + // err = os.WriteFile(expectedFilename, got, 0644) // if err != nil { // log.Fatal(err) // } diff --git a/pkg/acme/acme.go b/pkg/acme/acme.go index 2ccf9deee..c76b7adb9 100644 --- a/pkg/acme/acme.go +++ b/pkg/acme/acme.go @@ -5,7 +5,7 @@ import ( "crypto/x509" "encoding/pem" "fmt" - "io/ioutil" + "io" "log" "net/url" "sort" @@ -101,7 +101,7 @@ func NewVault(cfg *models.DNSConfig, vaultPath string, email string, server stri // It will return true if it issued or updated the certificate. func (c *certManager) IssueOrRenewCert(cfg *CertConfig, renewUnder int, verbose bool) (bool, error) { if !verbose { - acmelog.Logger = log.New(ioutil.Discard, "", 0) + acmelog.Logger = log.New(io.Discard, "", 0) } defer c.finalCleanUp() diff --git a/pkg/acme/directoryStorage.go b/pkg/acme/directoryStorage.go index 880ab208c..bf187d729 100644 --- a/pkg/acme/directoryStorage.go +++ b/pkg/acme/directoryStorage.go @@ -5,7 +5,6 @@ import ( "encoding/json" "encoding/pem" "fmt" - "io/ioutil" "os" "path/filepath" @@ -53,7 +52,7 @@ func (d directoryStorage) GetCertificate(name string) (*certificate.Resource, er return nil, err } // load cert - crtBytes, err := ioutil.ReadFile(d.certFile(name, "crt")) + crtBytes, err := os.ReadFile(d.certFile(name, "crt")) if err != nil { return nil, err } @@ -75,16 +74,16 @@ func (d directoryStorage) StoreCertificate(name string, cert *certificate.Resour if err != nil { return err } - if err = ioutil.WriteFile(d.certFile(name, "json"), jDAt, perms); err != nil { + if err = os.WriteFile(d.certFile(name, "json"), jDAt, perms); err != nil { return err } - if err = ioutil.WriteFile(d.certFile(name, "crt"), pub, perms); err != nil { + if err = os.WriteFile(d.certFile(name, "crt"), pub, perms); err != nil { return err } - if err = ioutil.WriteFile(d.certFile(name, "pem"), combined, perms); err != nil { + if err = os.WriteFile(d.certFile(name, "pem"), combined, perms); err != nil { return err } - return ioutil.WriteFile(d.certFile(name, "key"), priv, perms) + return os.WriteFile(d.certFile(name, "key"), priv, perms) } func (d directoryStorage) GetAccount(acmeHost string) (*Account, error) { @@ -101,7 +100,7 @@ func (d directoryStorage) GetAccount(acmeHost string) (*Account, error) { if err = dec.Decode(acct); err != nil { return nil, err } - keyBytes, err := ioutil.ReadFile(d.accountKeyFile(acmeHost)) + keyBytes, err := os.ReadFile(d.accountKeyFile(acmeHost)) if err != nil { return nil, err } @@ -124,7 +123,7 @@ func (d directoryStorage) StoreAccount(acmeHost string, account *Account) error if err != nil { return err } - if err = ioutil.WriteFile(d.accountFile(acmeHost), acctBytes, perms); err != nil { + if err = os.WriteFile(d.accountFile(acmeHost), acctBytes, perms); err != nil { return err } keyBytes, err := x509.MarshalECPrivateKey(account.key) @@ -133,5 +132,5 @@ func (d directoryStorage) StoreAccount(acmeHost string, account *Account) error } pemKey := &pem.Block{Type: "EC PRIVATE KEY", Bytes: keyBytes} pemBytes := pem.EncodeToMemory(pemKey) - return ioutil.WriteFile(d.accountKeyFile(acmeHost), pemBytes, perms) + return os.WriteFile(d.accountKeyFile(acmeHost), pemBytes, perms) } diff --git a/pkg/js/js.go b/pkg/js/js.go index 9660055c9..4246540b1 100644 --- a/pkg/js/js.go +++ b/pkg/js/js.go @@ -4,7 +4,6 @@ import ( _ "embed" // Used to embed helpers.js in the binary. "encoding/json" "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -40,7 +39,7 @@ var EnableFetch bool = false // ExecuteJavascript accepts a javascript string and runs it, returning the resulting dnsConfig. func ExecuteJavascript(file string, devMode bool, variables map[string]string) (*models.DNSConfig, error) { - script, err := ioutil.ReadFile(file) + script, err := os.ReadFile(file) if err != nil { return nil, err } @@ -111,7 +110,7 @@ func ExecuteJavascript(file string, devMode bool, variables map[string]string) ( func GetHelpers(devMode bool) string { if devMode { // Load the file: - b, err := ioutil.ReadFile(helpersJsFileName) + b, err := os.ReadFile(helpersJsFileName) if err != nil { log.Fatal(err) } @@ -143,7 +142,7 @@ func require(call otto.FunctionCall) otto.Value { printer.Debugf("requiring: %s (%s)\n", file, relFile) // quick fix, by replacing to linux slashes, to make it work with windows paths too. - data, err := ioutil.ReadFile(filepath.ToSlash(relFile)) + data, err := os.ReadFile(filepath.ToSlash(relFile)) if err != nil { throw(call.Otto, err.Error()) diff --git a/pkg/js/js_test.go b/pkg/js/js_test.go index b9aceb246..282560486 100644 --- a/pkg/js/js_test.go +++ b/pkg/js/js_test.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -28,7 +27,7 @@ func init() { } func TestParsedFiles(t *testing.T) { - files, err := ioutil.ReadDir(testDir) + files, err := os.ReadDir(testDir) if err != nil { t.Fatal(err) } @@ -80,7 +79,7 @@ func TestParsedFiles(t *testing.T) { } testName := name[:len(name)-3] expectedFile := filepath.Join(testDir, testName+".json") - expectedJSON, err := ioutil.ReadFile(expectedFile) + expectedJSON, err := os.ReadFile(expectedFile) if err != nil { t.Fatal(err) } @@ -88,7 +87,7 @@ func TestParsedFiles(t *testing.T) { as := string(actualJSON) _, _ = es, as // When debugging, leave behind the actual result: - //ioutil.WriteFile(expectedFile+".ACTUAL", []byte(es), 0644) + // os.WriteFile(expectedFile+".ACTUAL", []byte(es), 0644) testifyrequire.JSONEqf(t, es, as, "EXPECTING %q = \n```\n%s\n```", expectedFile, as) // For each domain, if there is a zone file, test against it: @@ -101,7 +100,7 @@ func TestParsedFiles(t *testing.T) { var dCount int for _, dc := range conf.Domains { zoneFile := filepath.Join(testDir, testName, dc.Name+".zone") - expectedZone, err := ioutil.ReadFile(zoneFile) + expectedZone, err := os.ReadFile(zoneFile) if err != nil { continue } @@ -119,7 +118,7 @@ func TestParsedFiles(t *testing.T) { as := actualZone if es != as { // On failure, leave behind the .ACTUAL file. - ioutil.WriteFile(zoneFile+".ACTUAL", []byte(actualZone), 0644) + os.WriteFile(zoneFile+".ACTUAL", []byte(actualZone), 0644) } testifyrequire.Equal(t, es, as, "EXPECTING %q =\n```\n%s```", zoneFile, as) } diff --git a/pkg/spflib/resolver.go b/pkg/spflib/resolver.go index ceec9072e..cf1cadf1e 100644 --- a/pkg/spflib/resolver.go +++ b/pkg/spflib/resolver.go @@ -3,7 +3,6 @@ package spflib import ( "encoding/json" "fmt" - "io/ioutil" "net" "os" "strings" @@ -137,5 +136,5 @@ func (c *cache) Save(filename string) error { } } dat, _ := json.MarshalIndent(outRecs, "", " ") - return ioutil.WriteFile(filename, dat, 0644) + return os.WriteFile(filename, dat, 0644) } diff --git a/providers/autodns/api.go b/providers/autodns/api.go index 2b97c494c..3b2da2815 100644 --- a/providers/autodns/api.go +++ b/providers/autodns/api.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "io" - "io/ioutil" "net/http" "sort" @@ -50,7 +49,7 @@ func (api *autoDnsProvider) request(method string, requestPath string, data inte } defer response.Body.Close() - responseText, _ := ioutil.ReadAll(response.Body) + responseText, _ := io.ReadAll(response.Body) if response.StatusCode != 200 { return nil, errors.New("Request to " + requestURL.Path + " failed: " + string(responseText)) } diff --git a/providers/bind/bindProvider.go b/providers/bind/bindProvider.go index b57ec255e..b2af7241c 100644 --- a/providers/bind/bindProvider.go +++ b/providers/bind/bindProvider.go @@ -17,13 +17,13 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/StackExchange/dnscontrol/v3/pkg/printer" - "io/ioutil" "os" "path/filepath" "strings" "time" + "github.com/StackExchange/dnscontrol/v3/pkg/printer" + "github.com/miekg/dns" "github.com/StackExchange/dnscontrol/v3/models" @@ -166,7 +166,7 @@ func (c *bindProvider) GetZoneRecords(domain string) (models.Records, error) { c.zonefile = filepath.Join(c.directory, makeFileName(c.filenameformat, domain, domain, "")) } - content, err := ioutil.ReadFile(c.zonefile) + content, err := os.ReadFile(c.zonefile) if os.IsNotExist(err) { // If the file doesn't exist, that's not an error. Just informational. c.zoneFileFound = false diff --git a/providers/cloudns/api.go b/providers/cloudns/api.go index 0216222aa..4bc981f7b 100644 --- a/providers/cloudns/api.go +++ b/providers/cloudns/api.go @@ -3,7 +3,7 @@ package cloudns import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "time" @@ -218,7 +218,7 @@ func (c *cloudnsProvider) get(endpoint string, params requestParams) ([]byte, er return []byte{}, err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) // Got error from API ? var errResp errorResponse diff --git a/providers/cscglobal/api.go b/providers/cscglobal/api.go index 9e308432b..708d2f1af 100644 --- a/providers/cscglobal/api.go +++ b/providers/cscglobal/api.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "os" "sort" @@ -538,7 +538,7 @@ func (client *providerClient) put(endpoint string, requestBody []byte) ([]byte, return nil, err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) if resp.StatusCode == 200 { return bodyString, nil } @@ -573,7 +573,7 @@ func (client *providerClient) delete(endpoint string) ([]byte, error) { return nil, err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) if resp.StatusCode == 200 { //printer.Printf("DEBUG: Delete successful (200)\n") return bodyString, nil @@ -609,7 +609,7 @@ func (client *providerClient) post(endpoint string, requestBody []byte) ([]byte, return nil, err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) //printer.Printf("------------------\n") //printer.Printf("DEBUG: resp.StatusCode == %d\n", resp.StatusCode) //printer.Printf("POST RESPONSE = %s\n", bodyString) @@ -650,7 +650,7 @@ func (client *providerClient) geturl(url string) ([]byte, error) { return nil, err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) if resp.StatusCode == 200 { return bodyString, nil } diff --git a/providers/desec/protocol.go b/providers/desec/protocol.go index 7f79b8f26..eb11376ed 100644 --- a/providers/desec/protocol.go +++ b/providers/desec/protocol.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strconv" @@ -284,7 +284,7 @@ retry: return []byte{}, resp, err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) // Got error from API ? if resp.StatusCode > 299 { if resp.StatusCode == 429 && retrycnt < 5 { @@ -350,7 +350,7 @@ retry: return []byte{}, err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) // Got error from API ? if resp.StatusCode > 299 { diff --git a/providers/easyname/api.go b/providers/easyname/api.go index 83e1d1863..2da122ad8 100644 --- a/providers/easyname/api.go +++ b/providers/easyname/api.go @@ -6,7 +6,7 @@ import ( "encoding/base64" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "time" ) @@ -71,7 +71,7 @@ func (c *easynameProvider) request(method, uri string, body *bytes.Buffer, resul return err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) json.Unmarshal(bodyString, &result) status := result.GetStatus() diff --git a/providers/hedns/hednsProvider.go b/providers/hedns/hednsProvider.go index ab09cba0b..37bbc4268 100644 --- a/providers/hedns/hednsProvider.go +++ b/providers/hedns/hednsProvider.go @@ -4,7 +4,6 @@ import ( "crypto/sha1" "encoding/json" "fmt" - "io/ioutil" "net/http" "net/http/cookiejar" "net/url" @@ -631,7 +630,7 @@ func (c *hednsProvider) saveSessionFile() error { } fileName := path.Join(c.SessionFilePath, sessionFileName) - err = ioutil.WriteFile(fileName, []byte(strings.Join(entries, "\n")), 0600) + err = os.WriteFile(fileName, []byte(strings.Join(entries, "\n")), 0600) return err } @@ -642,7 +641,7 @@ func (c *hednsProvider) loadSessionFile() error { } fileName := path.Join(c.SessionFilePath, sessionFileName) - bytes, err := ioutil.ReadFile(fileName) + bytes, err := os.ReadFile(fileName) if err != nil { if os.IsNotExist(err) { // Skip loading the session. diff --git a/providers/hetzner/api.go b/providers/hetzner/api.go index f481d136e..107d0625a 100644 --- a/providers/hetzner/api.go +++ b/providers/hetzner/api.go @@ -4,13 +4,13 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/StackExchange/dnscontrol/v3/pkg/printer" "io" - "io/ioutil" "net/http" "strconv" "strings" "time" + + "github.com/StackExchange/dnscontrol/v3/pkg/printer" ) const ( @@ -251,7 +251,7 @@ func (api *hetznerProvider) request(endpoint string, method string, request inte defer cleanupResponseBody() if !statusOK(resp.StatusCode) { - data, _ := ioutil.ReadAll(resp.Body) + data, _ := io.ReadAll(resp.Body) printer.Printf(string(data)) return fmt.Errorf("bad status code from HETZNER: %d not 200", resp.StatusCode) } diff --git a/providers/hostingde/api.go b/providers/hostingde/api.go index a3e2e516c..ec64f3e1d 100644 --- a/providers/hostingde/api.go +++ b/providers/hostingde/api.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "github.com/StackExchange/dnscontrol/v3/pkg/diff" @@ -252,7 +252,7 @@ func (hp *hostingdeProvider) get(service, method string, params request) (*respo return nil, fmt.Errorf("error occurred: %s", resp.Status) } - bodyBytes, err := ioutil.ReadAll(resp.Body) + bodyBytes, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("could not read response body: %w", err) } diff --git a/providers/internetbs/api.go b/providers/internetbs/api.go index 51c27c33d..beaabf135 100644 --- a/providers/internetbs/api.go +++ b/providers/internetbs/api.go @@ -3,7 +3,7 @@ package internetbs import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strings" ) @@ -71,7 +71,7 @@ func (c *internetbsProvider) get(endpoint string, params requestParams) ([]byte, return []byte{}, err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) // Got error from API ? var errResp errorResponse diff --git a/providers/msdns/powershell.go b/providers/msdns/powershell.go index ed7d63416..ae0e1fd85 100644 --- a/providers/msdns/powershell.go +++ b/providers/msdns/powershell.go @@ -4,11 +4,11 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/StackExchange/dnscontrol/v3/pkg/printer" - "io/ioutil" "log" "os" + "github.com/StackExchange/dnscontrol/v3/pkg/printer" + "github.com/StackExchange/dnscontrol/v3/models" "github.com/TomOnTime/utfutil" ps "github.com/bhendo/go-powershell" @@ -102,7 +102,7 @@ func generatePSZoneAll(dnsserver string) string { func (psh *psHandle) GetDNSZoneRecords(dnsserver, domain string) ([]nativeRecord, error) { - tmpfile, err := ioutil.TempFile("", "zonerecords.*.json") + tmpfile, err := os.CreateTemp("", "zonerecords.*.json") if err != nil { log.Fatal(err) } @@ -130,7 +130,7 @@ func (psh *psHandle) GetDNSZoneRecords(dnsserver, domain string) ([]nativeRecord //printer.Printf("CONTENTS = %s\n", contents) //printer.Printf("CONTENTS STR = %q\n", contents[:10]) //printer.Printf("CONTENTS HEX = %v\n", []byte(contents)[:10]) - //ioutil.WriteFile("/temp/list.json", contents, 0777) + //os.WriteFile("/temp/list.json", contents, 0777) var records []nativeRecord err = json.Unmarshal(contents, &records) if err != nil { diff --git a/providers/netcup/api.go b/providers/netcup/api.go index 61a115939..e6d0cb45c 100644 --- a/providers/netcup/api.go +++ b/providers/netcup/api.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" ) @@ -140,7 +140,7 @@ func (api *netcupProvider) get(action string, params interface{}) (json.RawMessa return nil, err } - bodyString, _ := ioutil.ReadAll(resp.Body) + bodyString, _ := io.ReadAll(resp.Body) respData := &response{} err = json.Unmarshal(bodyString, &respData) diff --git a/providers/octodns/octoyaml/js.go b/providers/octodns/octoyaml/js.go index 3e2dcb294..106614f88 100644 --- a/providers/octodns/octoyaml/js.go +++ b/providers/octodns/octoyaml/js.go @@ -2,8 +2,9 @@ package octoyaml import ( "encoding/json" + "os" + "github.com/StackExchange/dnscontrol/v3/pkg/printer" - "io/ioutil" "github.com/StackExchange/dnscontrol/v3/models" "github.com/StackExchange/dnscontrol/v3/pkg/transform" @@ -50,7 +51,7 @@ func ExecuteJavascript(script string, devMode bool) (*models.DNSConfig, error) { // GetHelpers returns the filename of helpers.js, or the esc'ed version. func GetHelpers(devMode bool) string { - d, err := ioutil.ReadFile("../pkg/js/helpers.js") + d, err := os.ReadFile("../pkg/js/helpers.js") if err != nil { panic(err) } @@ -63,7 +64,7 @@ func require(call otto.FunctionCall) otto.Value { } file := call.Argument(0).String() printer.Printf("requiring: %s\n", file) - data, err := ioutil.ReadFile(file) + data, err := os.ReadFile(file) if err != nil { throw(call.Otto, err.Error()) } diff --git a/providers/octodns/octoyaml/read.go b/providers/octodns/octoyaml/read.go index bb9e601bc..323602328 100644 --- a/providers/octodns/octoyaml/read.go +++ b/providers/octodns/octoyaml/read.go @@ -11,7 +11,6 @@ data we output models.RecordConfig objects. import ( "fmt" "io" - "io/ioutil" "reflect" "strconv" @@ -25,7 +24,7 @@ func ReadYaml(r io.Reader, origin string) (models.Records, error) { results := models.Records{} // Slurp the YAML into a string. - ydata, err := ioutil.ReadAll(r) + ydata, err := io.ReadAll(r) if err != nil { return nil, fmt.Errorf("can not read yaml filehandle: %w", err) } diff --git a/providers/octodns/octoyaml/rw_test.go b/providers/octodns/octoyaml/rw_test.go index f78db7a15..dba98322d 100644 --- a/providers/octodns/octoyaml/rw_test.go +++ b/providers/octodns/octoyaml/rw_test.go @@ -15,7 +15,6 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -39,7 +38,7 @@ func TestYamlWrite(t *testing.T) { // Read a .JS and make sure we can generate the expected YAML. - files, err := ioutil.ReadDir(testDir) + files, err := os.ReadDir(testDir) if err != nil { t.Fatal(err) } @@ -58,7 +57,7 @@ func TestYamlWrite(t *testing.T) { t.Run(f.Name(), func(t *testing.T) { fname := filepath.Join(testDir, f.Name()) fmt.Printf("Filename: %v\n", fname) - content, err := ioutil.ReadFile(fname) + content, err := os.ReadFile(fname) if err != nil { t.Fatal(err) } @@ -84,7 +83,7 @@ func TestYamlWrite(t *testing.T) { // Read expected YAML expectedFile := filepath.Join(testDir, basename+".yaml") - expectedData, err := ioutil.ReadFile(expectedFile) + expectedData, err := os.ReadFile(expectedFile) if err != nil { t.Fatal(err) } @@ -108,7 +107,7 @@ func TestYamlRead(t *testing.T) { minifyFlag := true - files, err := ioutil.ReadDir(testDir) + files, err := os.ReadDir(testDir) if err != nil { t.Fatal(err) } @@ -126,7 +125,7 @@ func TestYamlRead(t *testing.T) { // Parse YAML - content, err := ioutil.ReadFile(filepath.Join(testDir, f.Name())) + content, err := os.ReadFile(filepath.Join(testDir, f.Name())) if err != nil { if os.IsNotExist(err) { content = nil @@ -158,7 +157,7 @@ func TestYamlRead(t *testing.T) { // Read expected JSON expectedFile := filepath.Join(testDir, basename+".json") - expectedData, err := ioutil.ReadFile(expectedFile) + expectedData, err := os.ReadFile(expectedFile) if err != nil { if os.IsNotExist(err) { fmt.Println("SKIPPING") diff --git a/providers/packetframe/api.go b/providers/packetframe/api.go index e990a52e5..d237b9dd6 100644 --- a/providers/packetframe/api.go +++ b/providers/packetframe/api.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" ) @@ -189,7 +189,7 @@ func (api *packetframeProvider) get(endpoint string, target interface{}) error { } func (api *packetframeProvider) handleErrors(resp *http.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/providers/rwth/api.go b/providers/rwth/api.go index 1f13bd56d..5a3027f25 100644 --- a/providers/rwth/api.go +++ b/providers/rwth/api.go @@ -6,15 +6,16 @@ package rwth import ( "encoding/json" "fmt" - "github.com/StackExchange/dnscontrol/v3/models" - "github.com/StackExchange/dnscontrol/v3/pkg/printer" - "github.com/miekg/dns" - "io/ioutil" + "io" "net/http" "net/url" "strconv" "strings" "time" + + "github.com/StackExchange/dnscontrol/v3/models" + "github.com/StackExchange/dnscontrol/v3/pkg/printer" + "github.com/miekg/dns" ) const ( @@ -188,7 +189,7 @@ func (api *rwthProvider) request(endpoint string, method string, request url.Val defer cleanupResponseBody() if resp.StatusCode != http.StatusOK { - data, _ := ioutil.ReadAll(resp.Body) + data, _ := io.ReadAll(resp.Body) printer.Printf(string(data)) return fmt.Errorf("bad status code from RWTH: %d not 200", resp.StatusCode) }