tinygo
tinygo copied to clipboard
Reflect does not have field or method when compiling to wasm
I am trying to build my wasm code here using the following command:
tinygo build -o wasm.wasm -target wasm ./wasm
I get the following error:
# github.com/mitchellh/mapstructure
../../go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:421:16: dataType.PkgPath undefined (type reflect.Type has no field or method PkgPath)
../../go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:537:16: dataType.PkgPath undefined (type reflect.Type has no field or method PkgPath)
../../go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:565:22: MapOf not declared by package reflect
../../go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:713:21: MapOf not declared by package reflect
../../go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:806:23: SliceOf not declared by package reflect
../../go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:884:23: ArrayOf not declared by package reflect
I don't know if i is related to #575 #447 or not, so I create new issue here.
https://pkg.go.dev/reflect#StructOf is also missing; it is not super common but it's used in a wide variety of projects. See https://cs.github.com/?q=%22reflect.StructOf(%22%20language%3AGo&scopeName=All%20repos&scope=, for example.
Also, I'm not sure if the "wasm" label is appropriate; this is just that some reflect package APIs are not implemented.
While much work has been done on reflection recently, mapstructure
uses a number of features that we don't support yet, most notably creating types at runtime with MapOf
and friends. You code should build now, but might not run as you expect.