valyala / fasthttp

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
MIT License
21.94k stars 1.76k forks source link

Remove unnecessary build tag go1.21 #1721

Closed alexandear closed 9 months ago

alexandear commented 9 months ago

This PR reverts changes from #1695 because they are unnecessary.

Short Explanation

According to the Go documentation on Build Constraints, the constraint go1.20 applies to go1.20, go1.21, go1.22, and so on. Conversely, !go1.20 applies to go1.18 and go1.19.

Here's the relevant excerpt from the documentation:

During a particular build, the following build tags are satisfied: ...

  • a term for each Go major release, through the current version: "go1.1" from Go version 1.1 onward, "go1.12" from Go 1.12, and so on.

Long Explanation

Currently, fasthttp supports the following Go versions: 1.18, 1.19, 1.20, 1.21, 1.22. With build tags, we should ensure that:

Let's implement the changes in this PR and list the files used for building with different Go versions.

Go 1.18

This version compiles s2b_old.go:

go version go1.18 darwin/arm64
❯ go1.18 list -f '{{.GoFiles}}' ./...
[args.go b2s_old.go brotli.go bytesconv.go bytesconv_64.go bytesconv_table.go client.go coarsetime.go compress.go cookie.go doc.go fs.go header.go headers.go http.go lbclient.go methods.go nocopy.go peripconn.go round2_64.go s2b_old.go server.go status.go stream.go streaming.go strings.go tcp.go tcpdialer.go timer.go tls.go uri.go uri_unix.go userdata.go workerpool.go]
...

Right.

Go 1.19

This version compiles s2b_old.go:

❯ go1.19 version
go version go1.19 darwin/arm64
❯ go1.19 list -f '{{.GoFiles}}' ./...
[args.go b2s_old.go brotli.go bytesconv.go bytesconv_64.go bytesconv_table.go client.go coarsetime.go compress.go cookie.go doc.go fs.go header.go headers.go http.go lbclient.go methods.go nocopy.go peripconn.go round2_64.go s2b_old.go server.go status.go stream.go streaming.go strings.go tcp.go tcpdialer.go timer.go tls.go uri.go uri_unix.go userdata.go workerpool.go]
...

Right.

Go 1.20

This version compiles s2b_new.go:

❯ go1.20 version
go version go1.20 darwin/arm64
❯ go1.20 list -f '{{.GoFiles}}' ./...
[args.go b2s_new.go brotli.go bytesconv.go bytesconv_64.go bytesconv_table.go client.go coarsetime.go compress.go cookie.go doc.go fs.go header.go headers.go http.go lbclient.go methods.go nocopy.go peripconn.go round2_64.go s2b_new.go server.go status.go stream.go streaming.go strings.go tcp.go tcpdialer.go timer.go tls.go uri.go uri_unix.go userdata.go workerpool.go]
...

Yeah, this is what we want.

Go 1.21

This version compiles s2b_new.go:

❯ go1.21.7 version
go version go1.21.7 darwin/arm64
❯ go1.21.7 list -f '{{.GoFiles}}' ./...
[args.go b2s_new.go brotli.go bytesconv.go bytesconv_64.go bytesconv_table.go client.go coarsetime.go compress.go cookie.go doc.go fs.go header.go headers.go http.go lbclient.go methods.go nocopy.go peripconn.go round2_64.go s2b_new.go server.go status.go stream.go streaming.go strings.go tcp.go tcpdialer.go timer.go tls.go uri.go uri_unix.go userdata.go workerpool.go]
...

Right.

Go 1.22

This version compiles s2b_new.go:

❯ go version
go version go1.22.0 darwin/arm64
❯ go list -f '{{.GoFiles}}' ./...
[args.go b2s_new.go brotli.go bytesconv.go bytesconv_64.go bytesconv_table.go client.go coarsetime.go compress.go cookie.go doc.go fs.go header.go headers.go http.go lbclient.go methods.go nocopy.go peripconn.go round2_64.go s2b_new.go server.go status.go stream.go streaming.go strings.go tcp.go tcpdialer.go timer.go tls.go uri.go uri_unix.go userdata.go workerpool.go]
...

Cool.

alexandear commented 9 months ago

Looks like we have flaky tests.

erikdubbelboer commented 9 months ago

Thanks!