Sorry, the first one will get a "type [9223372036854775807]byte larger than address space" error. The following code will get the same error
var x *[^uint(0) >> 1]byte Is this error essential? On Saturday, February 27, 2021 at 11:00:26 PM UTC-5 tapi...@gmail.com wrote: > 1. > > func String2ByteSlice(s string) []byte { > return (*[^uint(0) >> 1]byte)(unsafe.Pointer(&s))[:len(s):len(s)] > } > > 2. > > func String2ByteSlice(s string) []byte { > return *(*[]byte)(unsafe.Pointer(&struct{string; int}{s, len(s)})) > } > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/411f0d80-eb3c-4737-94cf-1f4dd73e1678n%40googlegroups.com.