Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapstructure requires MapOf and friends #2115

Open
Rizary opened this issue Sep 15, 2021 · 2 comments
Open

mapstructure requires MapOf and friends #2115

Rizary opened this issue Sep 15, 2021 · 2 comments
Labels
reflection Needs further work on reflection wasm WebAssembly

Comments

@Rizary
Copy link

Rizary commented Sep 15, 2021

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/mapstructure@v1.1.2/mapstructure.go:421:16: dataType.PkgPath undefined (type reflect.Type has no field or method PkgPath)
../../go/pkg/mod/github.com/mitchellh/mapstructure@v1.1.2/mapstructure.go:537:16: dataType.PkgPath undefined (type reflect.Type has no field or method PkgPath)
../../go/pkg/mod/github.com/mitchellh/mapstructure@v1.1.2/mapstructure.go:565:22: MapOf not declared by package reflect
../../go/pkg/mod/github.com/mitchellh/mapstructure@v1.1.2/mapstructure.go:713:21: MapOf not declared by package reflect
../../go/pkg/mod/github.com/mitchellh/mapstructure@v1.1.2/mapstructure.go:806:23: SliceOf not declared by package reflect
../../go/pkg/mod/github.com/mitchellh/mapstructure@v1.1.2/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.

@mvdan
Copy link

mvdan commented Jul 13, 2022

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.

@dgryski
Copy link
Member

dgryski commented Mar 23, 2023

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.

@dgryski dgryski changed the title Reflect does not have field or method when compiling to wasm mapstructure requires MapOf and friends Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reflection Needs further work on reflection wasm WebAssembly
Projects
None yet
Development

No branches or pull requests

4 participants