Remove unnecessary build tag go1.21 #1721
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 togo1.20
,go1.21
,go1.22
, and so on. Conversely,!go1.20
applies togo1.18
andgo1.19
.Here's the relevant excerpt from the documentation:
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:
s2b_new.go
is included only when building with Go1.20
,1.21
,1.22
;s2b_old.go
is used for Go versions1.18
and1.19
.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
:Yeah, this is what we want.
Go 1.21
This version compiles
s2b_new.go
:Right.
Go 1.22
This version compiles
s2b_new.go
:Cool.