Replace uses of ioutil with io

This commit is contained in:
Adnan Maolood 2021-02-16 18:57:24 -05:00
parent d2001de5f3
commit 332dd253d0
2 changed files with 4 additions and 5 deletions

View File

@ -10,7 +10,7 @@ import (
"crypto/x509" "crypto/x509"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"log" "log"
"net/url" "net/url"
"os" "os"
@ -149,7 +149,7 @@ func main() {
// Handle response // Handle response
if gemini.StatusClass(resp.Status) == gemini.StatusSuccess { if gemini.StatusClass(resp.Status) == gemini.StatusSuccess {
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -2,7 +2,6 @@ package gemini
import ( import (
"io" "io"
"io/ioutil"
"strings" "strings"
"testing" "testing"
) )
@ -81,7 +80,7 @@ func TestReadResponse(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Logf("%#v", test.Raw) t.Logf("%#v", test.Raw)
resp, err := ReadResponse(ioutil.NopCloser(strings.NewReader(test.Raw))) resp, err := ReadResponse(io.NopCloser(strings.NewReader(test.Raw)))
if err != test.Err { if err != test.Err {
t.Errorf("expected err = %v, got %v", test.Err, err) t.Errorf("expected err = %v, got %v", test.Err, err)
} }
@ -95,7 +94,7 @@ func TestReadResponse(t *testing.T) {
if resp.Meta != test.Meta { if resp.Meta != test.Meta {
t.Errorf("expected meta = %s, got %s", test.Meta, resp.Meta) t.Errorf("expected meta = %s, got %s", test.Meta, resp.Meta)
} }
b, _ := ioutil.ReadAll(resp.Body) b, _ := io.ReadAll(resp.Body)
body := string(b) body := string(b)
if body != test.Body { if body != test.Body {
t.Errorf("expected body = %#v, got %#v", test.Body, body) t.Errorf("expected body = %#v, got %#v", test.Body, body)