CompileError: AsyncCompile: Wasm decoding failed

1,438 views
Skip to first unread message

Jon Killebrew

unread,
Apr 7, 2019, 2:10:13 AM4/7/19
to golang-nuts
Having issues getting WebAssembly (example at https://github.com/golang/go/wiki/WebAssembly).  I  am running a test website on the Google App Engine, and the website is running on Go.  I created all the objects according to the documentation provided on the page.  Now, I'm getting this error when loading the page:

CompileError: AsyncCompile: Wasm decoding failed: expected magic word 00 61 73 6d, found 21 3c 61 72 @+0

I'm expecting to see "Hello World" in the console of the browser when the run button is pressed, but instead I get the above error.  I'm running the latest version on Chrome on Win10.  The test website is at https://test-rest-api-236401.appspot.com/ currently running the code giving me the error.  Please help.  

Here's how the source is laid out on the page:
I'm currently running Go 1.12

/app.yaml  --used to run the website
/index.html  -- used to run the website and init the wasm go code
/main.go  -- used to run the website
/static/cmd/test.wasm   -- my compiled wasm hello world go code
/static/cmd/test.go  -- I don't believe I actually need this here since I have the .wasm file there.  I've tried it with and without it and still get the error.
/static/scripts/wasm_exec.js  -- version is the latest from the 1.12 source



Jon Killebrew

unread,
Apr 7, 2019, 11:08:50 AM4/7/19
to golang-nuts
Well I solved this one, and here was the solution for me for any that it might help.  When I wrote my initial test.go program (Hello world) it was in the same path as my main.go and both were using the function 'main'.  Well, I renamed the function in the test.go simply to 'test' and compiled the .wasm file.  Apparently, it doesn't like it when your function is not named 'main' or maybe if you don't have a function called 'main' in the code.  I renamed it back to 'main' in another dir, then compiled a new .wasm file and that seemed to work.  After publishing the files the "Hello world" program is being called on the page.  Hope this helps someone else.
Reply all
Reply to author
Forward
0 new messages