Closed acouvreur closed 4 days ago
This is https://github.com/tinygo-org/tinygo/pull/4156. This change is a backwards-incompatible change with the goal of being more compatible with existing Go code.
Looking at the code: https://github.com/tetratelabs/proxy-wasm-go-sdk/blob/v0.23.0/proxywasm/internal/hostcall_utils_tinygo.go#L29
func RawBytePtrToString(raw *byte, size int) string {
return *(*string)(unsafe.Pointer(&reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(raw)),
Len: uintptr(size),
Cap: uintptr(size),
}))
}
func RawBytePtrToByteSlice(raw *byte, size int) []byte {
return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(raw)),
Len: uintptr(size),
Cap: uintptr(size),
}))
}
The best way to do this nowadays is by using unsafe.String
and unsafe.Slice
.
(...perhaps this change was a bad idea in hindsight, maybe I should just have said "use unsafe.String
and unsafe.Slice
" because that's going to work on every compiler).
Ok, makes sense, thanks.
I'll update the proxy-wasm-go-sdk!
Got same issue: https://github.com/knqyf263/go-plugin/issues/64
I've just updated TinyGo to 0.32.0 and tinygo fails to compile with the following error:
You can take a look at https://github.com/acouvreur/sablier/pull/284 for more details.
Reverting back to 0.31.2 works!