TinyGo brings the Go programming language to embedded systems and to the modern web by creating a new compiler based on LLVM. You can compile and run TinyGo programs on over 60 different microcontroller boards such as the BBC micro:bit and the Arduino Uno. TinyGo can also produce WebAssembly (WASM) code which is very compact in size. You can compile programs for web browsers, as well as for server and edge computing environments that support the WebAssembly System Interface (WASI) family of interfaces. TinyGo is a Go compiler intended for use in small places such as microcontrollers, WebAssembly (Wasm), and command-line tools. It reuses libraries used by the Go language tools alongside LLVM to provide an alternative way to compile programs written in the Go programming language. While TinyGo embeds the Clang compiler to parse import "C" blocks, many features of Cgo are still unsupported.
Features
- The subset of Go that directly translates to C is well supported
- Slices are well supported
- Interfaces are quite stable and should work well in almost all cases
- Type switches and type asserts are also supported
- Closures and bound methods are supported, for example inline anonymous (lambda-like) functions
- The defer keyword is almost entirely supported, with the exception of deferring some builtin functions