fastjson
fastjson copied to clipboard
func s2s use deprecated code in golang 1.20
Same problem has been solved in fasthttp in https://github.com/valyala/fasthttp/pull/1481 Original code: func s2b(s string) (b []byte) { strh := (*reflect.StringHeader)(unsafe.Pointer(&s)) sh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) sh.Data = strh.Data sh.Len = strh.Len sh.Cap = strh.Len return b }
Was replaced in b2s_new.go // s2b converts string to a byte slice without memory allocation. func s2b(s string) []byte { return unsafe.Slice(unsafe.StringData(s), len(s)) }