Wasm Builders

Cover image for Getting started with Wasm in Golang
Philippe Charrière
Philippe Charrière

Posted on

Getting started with Wasm in Golang

Some months ago, I wrote a blog post about Wasm with Golang hosted on the blog of Suborbital: Foundations: Wasm in Golang is fantastic.

For my first post on Wasm Builders, I preferred to make it a "hands-on" version rather than copy and paste the former article.

For that, I created a project on GitLab configured to be opened with GitPod. This project is a "self-running" hands-on (you can do it on your own) about creating wasm programs for the browser with GoLang.

This project is like a sandbox with all you need to start playing with WASM, GoLang and TinyGo (in your browser) right now without installing anything. So, to benefit from that, you have to open this project with Gitpod.

Remark: the free plan of Gitpod is enough to realize the exercises.

This hands-on is composed of 7 small exercises:

  • ./01-getting-started: display a message in the browser console when loading wasm GoLang code
  • ./02-interacting-with-dom: add an html tag to the web page when loading wasm GoLang code
  • ./03-call-a-go-function: create a wasm GoLang function with a string parameter that returns a string and call it from JavaScript
  • ./04-return-a-json-object: create a wasm GoLang function that returns a JavaScript object
  • ./05-json-object-as-parameter: create a wasm GoLang function with a json object as parameter
  • ./06-array-as-parameter: create a wasm GoLang function with an array as a parameter
  • ./07-return-an-array: create a wasm GoLang function that returns an array

So, you can start the hands-on here: https://gitlab.com/k33g_org/wasm.builders/01-wasm-golang-browser

🖐 Again, there is nothing to install. You can open directly the project, but you should fork it if you want to be able to commit your changes.

The first opening could take a moment because of the pull of the Docker image needed to create the workspace.

Enjoy your exercises and tell me if you want more.

Discussion (0)