Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Go 1.15 #1379

Merged
merged 5 commits into from Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -8,7 +8,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
1 change: 0 additions & 1 deletion allocation_test.go
Expand Up @@ -5,7 +5,6 @@ package fasthttp

import (
"net"

"testing"
)

Expand Down
4 changes: 2 additions & 2 deletions brotli_test.go
Expand Up @@ -4,7 +4,7 @@ import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"io"
"testing"
)

Expand Down Expand Up @@ -91,7 +91,7 @@ func testBrotliCompressSingleCase(s string) error {
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
body, err := ioutil.ReadAll(zr)
body, err := io.ReadAll(zr)
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
Expand Down
3 changes: 1 addition & 2 deletions bytesconv_table_gen.go
Expand Up @@ -6,7 +6,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
)

Expand Down Expand Up @@ -107,7 +106,7 @@ func main() {
fmt.Fprintf(w, "const quotedArgShouldEscapeTable = %q\n", quotedArgShouldEscapeTable)
fmt.Fprintf(w, "const quotedPathShouldEscapeTable = %q\n", quotedPathShouldEscapeTable)

if err := ioutil.WriteFile("bytesconv_table.go", w.Bytes(), 0660); err != nil {
if err := os.WriteFile("bytesconv_table.go", w.Bytes(), 0660); err != nil {
log.Fatal(err)
}
}
Expand Down
10 changes: 5 additions & 5 deletions client_timing_test.go
Expand Up @@ -3,7 +3,7 @@ package fasthttp
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"runtime"
Expand Down Expand Up @@ -169,7 +169,7 @@ func BenchmarkNetHTTPClientDoFastServer(b *testing.B) {
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d", resp.StatusCode)
}
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
Expand Down Expand Up @@ -297,7 +297,7 @@ func benchmarkNetHTTPClientGetEndToEndTCP(b *testing.B, parallelism int) {
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode, http.StatusOK)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
Expand Down Expand Up @@ -427,7 +427,7 @@ func benchmarkNetHTTPClientGetEndToEndInmemory(b *testing.B, parallelism int) {
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode, http.StatusOK)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
Expand Down Expand Up @@ -554,7 +554,7 @@ func benchmarkNetHTTPClientEndToEndBigResponseInmemory(b *testing.B, parallelism
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode, http.StatusOK)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
Expand Down
7 changes: 2 additions & 5 deletions client_timing_wait_test.go
@@ -1,10 +1,7 @@
//go:build go1.11
// +build go1.11

package fasthttp

import (
"io/ioutil"
"io"
"net"
"net/http"
"strings"
Expand Down Expand Up @@ -146,7 +143,7 @@ func benchmarkNetHTTPClientGetEndToEndWaitConnInmemory(b *testing.B, parallelism
if resp.StatusCode != http.StatusOK {
b.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode, http.StatusOK)
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
b.Fatalf("unexpected error when reading response body: %v", err)
Expand Down
5 changes: 2 additions & 3 deletions client_unix_test.go
Expand Up @@ -5,7 +5,6 @@ package fasthttp

import (
"io"
"io/ioutil"
"net"
"net/http"
"strings"
Expand All @@ -32,7 +31,7 @@ func TestRstConnResponseWhileSending(t *testing.T) {

// Read at least one byte of the header
// Otherwise we would have an unsolicited response
_, err = ioutil.ReadAll(io.LimitReader(conn, 1))
_, err = io.ReadAll(io.LimitReader(conn, 1))
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -94,7 +93,7 @@ func TestRstConnClosedWithoutResponse(t *testing.T) {

// Read at least one byte of the header
// Otherwise we would have an unsolicited response
_, err = ioutil.ReadAll(io.LimitReader(conn, 1))
_, err = io.ReadAll(io.LimitReader(conn, 1))
if err != nil {
t.Error(err)
}
Expand Down
6 changes: 3 additions & 3 deletions compress_test.go
Expand Up @@ -3,7 +3,7 @@ package fasthttp
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"testing"
"time"
)
Expand Down Expand Up @@ -173,7 +173,7 @@ func testGzipCompressSingleCase(s string) error {
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
body, err := ioutil.ReadAll(zr)
body, err := io.ReadAll(zr)
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
Expand All @@ -196,7 +196,7 @@ func testFlateCompressSingleCase(s string) error {
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
body, err := ioutil.ReadAll(zr)
body, err := io.ReadAll(zr)
if err != nil {
return fmt.Errorf("unexpected error: %w. s=%q", err, s)
}
Expand Down
4 changes: 2 additions & 2 deletions fasthttpadaptor/adaptor_test.go
Expand Up @@ -2,7 +2,7 @@ package fasthttpadaptor

import (
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestNewFastHTTPHandler(t *testing.T) {
if r.RemoteAddr != expectedRemoteAddr {
t.Fatalf("unexpected remoteAddr %q. Expecting %q", r.RemoteAddr, expectedRemoteAddr)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
r.Body.Close()
if err != nil {
t.Fatalf("unexpected error when reading request body: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions fasthttpadaptor/request.go
Expand Up @@ -2,7 +2,7 @@ package fasthttpadaptor

import (
"bytes"
"io/ioutil"
"io"
"net/http"
"net/url"

Expand All @@ -28,7 +28,7 @@ func ConvertRequest(ctx *fasthttp.RequestCtx, r *http.Request, forServer bool) e
r.RemoteAddr = ctx.RemoteAddr().String()
r.Host = string(ctx.Host())
r.TLS = ctx.TLSConnectionState()
r.Body = ioutil.NopCloser(bytes.NewReader(body))
r.Body = io.NopCloser(bytes.NewReader(body))
r.URL = rURL

if forServer {
Expand Down
5 changes: 2 additions & 3 deletions fasthttpproxy/proxy_env.go
Expand Up @@ -9,9 +9,8 @@ import (
"sync/atomic"
"time"

"golang.org/x/net/http/httpproxy"

"github.com/valyala/fasthttp"
"golang.org/x/net/http/httpproxy"
)

const (
Expand All @@ -32,7 +31,7 @@ func FasthttpProxyHTTPDialer() fasthttp.DialFunc {
return FasthttpProxyHTTPDialerTimeout(0)
}

// FasthttpProxyHTTPDialer returns a fasthttp.DialFunc that dials using
// FasthttpProxyHTTPDialerTimeout returns a fasthttp.DialFunc that dials using
// the env(HTTP_PROXY, HTTPS_PROXY and NO_PROXY) configured HTTP proxy using the given timeout.
//
// Example usage:
Expand Down
3 changes: 1 addition & 2 deletions fasthttputil/inmemory_listener_test.go
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"sync"
Expand Down Expand Up @@ -147,7 +146,7 @@ func testInmemoryListenerHTTPSingle(t *testing.T, client *http.Client, content s
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
b, err := ioutil.ReadAll(res.Body)
b, err := io.ReadAll(res.Body)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions fasthttputil/pipeconns_test.go
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net"
"testing"
"time"
Expand Down Expand Up @@ -162,7 +161,7 @@ func testPipeConnsCloseWhileReadWrite(t *testing.T) {
readCh := make(chan error)
go func() {
var err error
if _, err = io.Copy(ioutil.Discard, c1); err != nil {
if _, err = io.Copy(io.Discard, c1); err != nil {
if err != errConnectionClosed {
err = fmt.Errorf("unexpected error: %w", err)
} else {
Expand Down
3 changes: 1 addition & 2 deletions fs.go
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"html"
"io"
"io/ioutil"
"mime"
"net/http"
"os"
Expand Down Expand Up @@ -1377,7 +1376,7 @@ func readFileHeader(f *os.File, compressed bool, fileEncoding string) ([]byte, e
R: r,
N: 512,
}
data, err := ioutil.ReadAll(lr)
data, err := io.ReadAll(lr)
if _, err := f.Seek(0, 0); err != nil {
return nil, err
}
Expand Down
16 changes: 6 additions & 10 deletions fs_test.go
@@ -1,14 +1,10 @@
// go:build !windows
// Don't run FS tests on windows as it isn't compatible for now.

package fasthttp

import (
"bufio"
"bytes"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"path"
Expand Down Expand Up @@ -158,13 +154,13 @@ func TestServeFileSmallNoReadFrom(t *testing.T) {

teststr := "hello, world!"

tempdir, err := ioutil.TempDir("", "httpexpect")
tempdir, err := os.MkdirTemp("", "httpexpect")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tempdir)

if err := ioutil.WriteFile(
if err := os.WriteFile(
path.Join(tempdir, "hello"), []byte(teststr), 0666); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -412,7 +408,7 @@ func getFileContents(path string) ([]byte, error) {
return nil, err
}
defer f.Close()
return ioutil.ReadAll(f)
return io.ReadAll(f)
}

func TestParseByteRangeSuccess(t *testing.T) {
Expand Down Expand Up @@ -703,7 +699,7 @@ func fsHandlerTest(t *testing.T, requestHandler RequestHandler, filenames []stri
f.Close()
continue
}
data, err := ioutil.ReadAll(f)
data, err := io.ReadAll(f)
f.Close()
if err != nil {
t.Fatalf("cannot read file contents %q: %v", name, err)
Expand All @@ -714,7 +710,7 @@ func fsHandlerTest(t *testing.T, requestHandler RequestHandler, filenames []stri
if ctx.Response.bodyStream == nil {
t.Fatalf("response body stream must be non-empty")
}
body, err := ioutil.ReadAll(ctx.Response.bodyStream)
body, err := io.ReadAll(ctx.Response.bodyStream)
if err != nil {
t.Fatalf("error when reading response body stream: %v", err)
}
Expand All @@ -733,7 +729,7 @@ func fsHandlerTest(t *testing.T, requestHandler RequestHandler, filenames []stri
if ctx.Response.bodyStream == nil {
t.Fatalf("response body stream must be non-empty")
}
body, err := ioutil.ReadAll(ctx.Response.bodyStream)
body, err := io.ReadAll(ctx.Response.bodyStream)
if err != nil {
t.Fatalf("error when reading response body stream: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
@@ -1,10 +1,10 @@
module github.com/valyala/fasthttp

go 1.15
go 1.16

require (
github.com/andybalholm/brotli v1.0.4
github.com/klauspost/compress v1.15.0
github.com/klauspost/compress v1.15.9
github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/tcplisten v1.0.0
golang.org/x/crypto v0.0.0-20220214200702-86341886e292
Expand Down
4 changes: 2 additions & 2 deletions go.sum
@@ -1,7 +1,7 @@
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U=
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
Expand Down