DEV Community

Cover image for (Tiny)Go to WebAssembly

(Tiny)Go to WebAssembly

Sendil Kumar on July 05, 2019

Gophers not only look cute but also they are powerful. I ❤️ statically typed languages and Golang is statically typed too. Golang is syntacti...
Collapse
 
timonweb profile image
Tim Kamanin 🚀

tinygo bundle sizes look very promising, however didn't work for me. After compiling to main.wasm with tinygo I get the following error in Chrome console: 'Import #0 module="env" error: module is not an object or function'. What could be wrong here?

Collapse
 
sendilkumarn profile image
Sendil Kumar • Edited

Ahh.. sorry I have to update it. Can you pull the wasm_exec.js from the tinygo repo instead of the attached file

Updated the post

Collapse
 
timonweb profile image
Tim Kamanin 🚀

It's working, thanks a lot for such a quick response! Btw, are there any limitations imposed by tinygo? Is it capable to compile any Go code to .wasm?

Thread Thread
 
sendilkumarn profile image
Sendil Kumar

Yeah there are some limitations. I am drafting a post on that. I am also experimenting a bit. Sooner will have a complete list.

Collapse
 
emaphp profile image
Emmanuel Antico

Great post. Couldn't work around the first example though. Apparently this works different on Linux archs because here it is suggested we generate wasm_exec.js by doing cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .. That did the trick for me.