diff --git a/cmd/golangorg/server.go b/cmd/golangorg/server.go index d0191b65..fff2e07f 100644 --- a/cmd/golangorg/server.go +++ b/cmd/golangorg/server.go @@ -18,7 +18,6 @@ import ( "html/template" "io" "io/fs" - "io/ioutil" "log" "net/http" "net/url" @@ -811,7 +810,7 @@ func (s *seekableFS) Open(name string) (fs.File, error) { if info.IsDir() { return f, nil } - data, err := ioutil.ReadAll(f) + data, err := io.ReadAll(f) if err != nil { f.Close() return nil, err diff --git a/internal/gitfs/git.go b/internal/gitfs/git.go index ff391f38..06325b26 100644 --- a/internal/gitfs/git.go +++ b/internal/gitfs/git.go @@ -11,7 +11,6 @@ import ( "fmt" "io" "io/fs" - "io/ioutil" "net/http" "strings" ) @@ -42,7 +41,7 @@ func (r *Repo) handshake() error { if err != nil { return fmt.Errorf("handshake: %v", err) } - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if resp.StatusCode != 200 { return fmt.Errorf("handshake: %v\n%s", resp.Status, data) } @@ -130,7 +129,7 @@ func (r *Repo) refs(prefixes ...string) ([]ref, error) { return nil, fmt.Errorf("refs: %v", err) } defer resp.Body.Close() - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if resp.StatusCode != 200 { return nil, fmt.Errorf("refs: %v\n%s", resp.Status, data) } @@ -222,7 +221,7 @@ func (r *Repo) fetch(h Hash) (fs.FS, error) { } defer resp.Body.Close() if resp.StatusCode != 200 { - data, _ := ioutil.ReadAll(resp.Body) + data, _ := io.ReadAll(resp.Body) return nil, fmt.Errorf("fetch: %v\n%s\n%s", resp.Status, data, hex.Dump(postbody)) } if ct := resp.Header.Get("Content-Type"); ct != "application/x-git-upload-pack-result" { diff --git a/internal/gitfs/git_test.go b/internal/gitfs/git_test.go index 504ca850..33546f04 100644 --- a/internal/gitfs/git_test.go +++ b/internal/gitfs/git_test.go @@ -6,7 +6,7 @@ package gitfs import ( "io/fs" - "io/ioutil" + "os" "testing" ) @@ -49,7 +49,7 @@ func TestGitHub(t *testing.T) { } func TestPack(t *testing.T) { - data, err := ioutil.ReadFile("testdata/scratch.pack") + data, err := os.ReadFile("testdata/scratch.pack") if err != nil { t.Fatal(err) } diff --git a/internal/gitfs/pack.go b/internal/gitfs/pack.go index 6913312a..7b3ba9cb 100644 --- a/internal/gitfs/pack.go +++ b/internal/gitfs/pack.go @@ -10,7 +10,7 @@ import ( "crypto/sha1" "encoding/binary" "fmt" - "io/ioutil" + "io" ) // unpack parses data, which is a Git pack-formatted archive, @@ -142,7 +142,7 @@ func unpackObject(s *store, objs []byte, off int) (typ objType, h Hash, content if err != nil { return fail(fmt.Errorf("invalid object deflate: %v", err)) } - data, err := ioutil.ReadAll(zr) + data, err := io.ReadAll(zr) if err != nil { return fail(fmt.Errorf("invalid object: bad deflate: %v", err)) } diff --git a/internal/pkgdoc/doc.go b/internal/pkgdoc/doc.go index e915b70a..ef1712a3 100644 --- a/internal/pkgdoc/doc.go +++ b/internal/pkgdoc/doc.go @@ -17,7 +17,6 @@ import ( "go/token" "io" "io/fs" - "io/ioutil" "log" "net/http" "net/url" @@ -181,7 +180,7 @@ func (d *docs) open(dir string, mode mode, goos, goarch string) *Page { if err != nil { return nil, err } - return ioutil.NopCloser(bytes.NewReader(data)), nil + return io.NopCloser(bytes.NewReader(data)), nil } // Make the syscall/js package always visible by default. diff --git a/internal/play/proxy.go b/internal/play/proxy.go index 1b3e24d2..069d4a8e 100644 --- a/internal/play/proxy.go +++ b/internal/play/proxy.go @@ -10,7 +10,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "log" "net/http" "regexp" @@ -117,7 +116,7 @@ func makeCompileRequest(ctx context.Context, backend string, req *Request, res * defer r.Body.Close() if r.StatusCode != http.StatusOK { - b, _ := ioutil.ReadAll(r.Body) + b, _ := io.ReadAll(r.Body) return fmt.Errorf("bad status: %v body:\n%s", r.Status, b) } diff --git a/internal/screentest/screentest.go b/internal/screentest/screentest.go index fe896819..841fafaa 100644 --- a/internal/screentest/screentest.go +++ b/internal/screentest/screentest.go @@ -123,7 +123,6 @@ import ( "image/png" "io" "io/fs" - "io/ioutil" "log" "net/http" "net/url" @@ -742,9 +741,9 @@ func (tc *testcase) screenshot(ctx context.Context, url, file string, return nil, fmt.Errorf("object.NewReader(ctx): %w", err) } else if err == nil { defer r.Close() - data, err = ioutil.ReadAll(r) + data, err = io.ReadAll(r) if err != nil { - return nil, fmt.Errorf("ioutil.ReadAll(...): %w", err) + return nil, fmt.Errorf("io.ReadAll(...): %w", err) } } } else if cache { diff --git a/internal/tmplfunc/tmpl.go b/internal/tmplfunc/tmpl.go index 3bca424d..d3432e4b 100644 --- a/internal/tmplfunc/tmpl.go +++ b/internal/tmplfunc/tmpl.go @@ -82,7 +82,7 @@ package tmplfunc import ( "fmt" "io/fs" - "io/ioutil" + "os" "path" "path/filepath" @@ -234,7 +234,7 @@ func MustParseGlob(t Template, pattern string) { func readFileOS(file string) (name string, b []byte, err error) { name = filepath.Base(file) - b, err = ioutil.ReadFile(file) + b, err = os.ReadFile(file) return } diff --git a/internal/webtest/webtest.go b/internal/webtest/webtest.go index ef77276f..12222fbe 100644 --- a/internal/webtest/webtest.go +++ b/internal/webtest/webtest.go @@ -153,10 +153,10 @@ import ( "fmt" "io" "io/fs" - "io/ioutil" "net/http" "net/http/httptest" "net/url" + "os" "path/filepath" "regexp" "strings" @@ -244,7 +244,7 @@ func test(t *testing.T, glob string, do func(*case_) error) { } for _, file := range files { t.Run(filepath.Base(file), func(t *testing.T) { - data, err := ioutil.ReadFile(file) + data, err := os.ReadFile(file) if err != nil { t.Fatal(err) } @@ -345,7 +345,7 @@ func (c *case_) runServer(addr string) error { if err != nil { return fmt.Errorf("%s:%d: %s %s: %s", c.file, c.line, c.method, c.url, err) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) resp.Body.Close() if err != nil { return fmt.Errorf("%s:%d: %s %s: reading body: %s", c.file, c.line, c.method, c.url, err) diff --git a/internal/webtest/webtest_test.go b/internal/webtest/webtest_test.go index cb3e2b01..4bb23722 100644 --- a/internal/webtest/webtest_test.go +++ b/internal/webtest/webtest_test.go @@ -6,8 +6,8 @@ package webtest import ( "fmt" - "io/ioutil" "net/http" + "os" "path/filepath" "strings" "testing" @@ -43,7 +43,7 @@ func testWebtest(t *testing.T, glob string, do func(*case_) error) { } for _, file := range files { t.Run(filepath.Base(file), func(t *testing.T) { - data, err := ioutil.ReadFile(file) + data, err := os.ReadFile(file) if err != nil { t.Fatal(err) }