-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
unsafe: {String,SliceData} cannot be guarded with build tags #58554
Comments
if you change go version in go.mod to go 1.16, unsafe.Slice report error too. |
@cuiweixie thank you, something must've been wrong in my local setup last night -- I confirm this also happens for |
This is true of builtins in general too. It's unfortunate but hard to fix. Note that setting |
Looks same as #58342. |
Can this by solved by supporting |
#59033 is probably relevant. |
I was hit by this as well, exactly with |
Duplicate of #59033 |
If a go.mod uses anything prior to
go 1.20
, a library cannot useunsafe.SliceData
even if the usage is guarded in a file with Go version build tags (//go:build go1.20
).Using
unsafe.SliceData
orunsafe.String
will print something along the lines of...This restriction did not exist forA similar thing happens when usingunsafe.Slice
--unsafe.Slice
could be guarded with build tags.unsafe.Slice
with a go.mod that indicates 1.16.Does this issue reproduce with the latest release?
Yes.
What did you do?
https://go.dev/play/p/fK1zbeRZrwW
What did you expect to see?
In the above playground link, no error for both Go 1.19 and Go 1.20.
What did you see instead?
In the above playground link, no error for Go 1.19 but a compile time error for Go 1.20.
The text was updated successfully, but these errors were encountered: