Skip to content

util: replace deprecated reflect.StringHeader/SliceHeader#121

Open
c-tonneslan wants to merge 1 commit into
valyala:masterfrom
c-tonneslan:fix/replace-deprecated-reflect-headers
Open

util: replace deprecated reflect.StringHeader/SliceHeader#121
c-tonneslan wants to merge 1 commit into
valyala:masterfrom
c-tonneslan:fix/replace-deprecated-reflect-headers

Conversation

@c-tonneslan
Copy link
Copy Markdown

Closes #99.

reflect.StringHeader and reflect.SliceHeader were deprecated in Go 1.20 in favour of the unsafe.String / unsafe.Slice / unsafe.StringData / unsafe.SliceData family. Same swap that landed in fasthttp via #1481.

While I was in there I also moved b2s off the older `*(*string)(unsafe.Pointer(&b))` form onto `unsafe.String`, which is the documented spelling for this conversion. Behaviour is unchanged and tests pass.

reflect.StringHeader and reflect.SliceHeader are deprecated since
Go 1.20 in favour of unsafe.StringData/SliceData/String/Slice. Same
swap that landed in fasthttp (#1481).

s2b becomes a one-liner, b2s also moves off the dodgy
*(*string)(unsafe.Pointer(&b)) trick onto unsafe.String, which is
the documented spelling for this conversion. Behaviour is unchanged.

Closes valyala#99

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

func s2s use deprecated code in golang 1.20

1 participant