Hi, I'm wanting to use the Go 1.26 built-in new function in WASM plugins (via Extism), but when compiling with TinyGo all the values are blank.
Here's an example plugin showing the behaviour:
type Person struct {
Name *string
Age *int
}
func main() {}
//go:wasmexport person
func person() int32 {
name := "Dickens"
age := 31
charles := Person{
Name: new(name),
Age: new(age),
}
// Host application receives:
// TinyGo: {"Name":"","Age":0}
// Go: {"Name":"Dickens","Age":31}
// charles := Person{
// Name: &name,
// Age: &age,
// }
// Host application receives:
// TinyGo: {"Name":"Dickens","Age":31}
// Go: {"Name":"Dickens","Age":31}
if err := pdk.OutputJSON(charles); err != nil {
return 1
}
return 0
}
I'm using macos 15.7.5:
$ tinygo version
=> tinygo version 0.41.1 darwin/arm64 (using go version go1.26.3 and LLVM version 20.1.1)
$ go version
=> go version go1.26.3 darwin/arm64
$ tinygo build -target wasi -buildmode=c-shared -o plugin-tiny.wasm .
$ GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o plugin-go.wasm .
Hi, I'm wanting to use the Go 1.26 built-in
newfunction in WASM plugins (via Extism), but when compiling with TinyGo all the values are blank.Here's an example plugin showing the behaviour:
I'm using macos 15.7.5: