12 Go for other architectures

 

This chapter covers

  • Exploring WebAssembly and TinyGo
  • Developing and integrating Go, JavaScript, and HTML via WebAssembly
  • Compiling, testing, and debugging WebAssembly applications
  • Investigating TinyGo’s unique features
  • Flashing a microcontroller using TinyGo

Congratulations on the progress you’ve made and the knowledge you’ve gained throughout this journey. We hope you found it fulfilling! Consider this chapter an added bonus where we explore two technologies revolving around Go: Web­Assembly (Wasm) and TinyGo. Both are ways of writing and compiling code for small processors, such as those found in web browsers or microcontrollers used in robotics and the Internet of Things (IoT)—environments where memory and CPU resources are limited.

Your projects so far have been running on your machine, but most of the time, we have to write programs that will end up running on machines other than our own. Those machines might be different from ours regarding available resources, operating system, CPU architecture, or the networks they’re connected to. Go can help us build executables for specific environments. As an example, we’ll start by exploring Wasm.

12.1 Getting started with Wasm

12.1.1 Some practice with Hello Wasm

12.1.2 Write a file server

12.2 Multiplication quiz project

12.2.1 Displaying random numbers on the HTML page

12.2.2 Registering functions in Go

12.2.3 Reading an input from the page

12.3 TinyGo

12.3.1 Building a simple TinyGo application

12.3.2 Differences with Go

12.3.3 Debugging and deploying with TinyGo

Summary