-
Notifications
You must be signed in to change notification settings - Fork 925
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
examples/wasm: update export example to show the use of the go:wasmimport directive #3589
Conversation
…port directive Signed-off-by: deadprogram <ron@hybridgroup.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//go:wasmimport
is meant for only importing functions, but it also unintentionally exports functions.
Do we want to officially support that, or add a new //go:wasmexport
instead?
The proposal at golang/go#38248 was accepted and already implemented here golang/go@02411bc so in the interest of keeping compatibility we should probably do the same thing for now. |
@@ -8,12 +8,12 @@ import ( | |||
func main() { | |||
} | |||
|
|||
//export add | |||
//go:wasmimport add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this update is premature, go:wasmimport is only supported on functions with no body that get linked at runtime to exports of other modules.
Here it seems that the //export directive is intended to ask the compiler to add the function to the list of exports of the module, or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah OK. I totally misunderstood what was happening here. Thanks for the clarification.
I have made a PR to fix this: #3610 That said, I do agree it would be a good idea to add an example with |
I think the best thing to come out of this PR is to prevent me from doing what is in this PR. 😸 Thanks @achille-roussel and @aykevl I will close this one since it does not actually do anything we need. |
This PR updates the wasm "export" example to show the use of the
go:wasmimport
directive. See #3165 for details.