Skip to content

Commit 45ebfa0

Browse files
juliaogrisdeadprogram
authored andcommitted
Fix wasm docs for tinygo 0.26.0
As of 0.26.0 the go //export directive for functions defined in JS, otherwise we get a `tinygo:wasm-ld: error` of `undefined symbol`. Along with this change the `main.` package prefix is no longer required. Thanks to @camh- for working this out first! Issue: tinygo-org/tinygo#3283
1 parent a60ab04 commit 45ebfa0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

content/docs/guides/webassembly.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ func main() {
1616
}
1717

1818
// This function is imported from JavaScript, as it doesn't define a body.
19-
// You should define a function named 'main.add' in the WebAssembly 'env'
19+
// You should define a function named 'add' in the WebAssembly 'env'
2020
// module from JavaScript.
21+
//
22+
//export add
2123
func add(x, y int) int
2224

2325
// This function is exported to JavaScript, so can be called using
@@ -34,7 +36,7 @@ Related JavaScript would look something like this:
3436
// Providing the environment object, used in WebAssembly.instantiateStreaming.
3537
// This part goes after "const go = new Go();" declaration.
3638
go.importObject.env = {
37-
'main.add': function(x, y) {
39+
'add': function(x, y) {
3840
return x + y
3941
}
4042
// ... other functions

0 commit comments

Comments
 (0)