TinyGo: A Go Compiler For Small Places

TinyGo: A Go Compiler For Small Places

I started my journey with Go more than a year ago. Since then I have tried to find more and more opportunities to play with the language.

At first, I didn’t know that I would like it that much. I thought that I’m just adding another language into my toolbox. But as time goes, and I’m writing more and more Go code, I understand how much I love this language and how much I missed it when I’m writing code in another language.
Isn’t it love? 

When I’m learning something new, like a new system, a new language, or anything else, I love to get my hands dirty with it. I feel that I learn much faster – I’m facing errors, doing mistakes, I read more and in general, I’m gaining more experience with it.
And the same goes for Golang.

After I’m gaining enough confidence, I tend to search for something that will take me out of my comfort zone.
And there you have it – TinyGo.

We never expected Go to be an embedded language and so its got serious problems

Rob Pike


TinyGo is a project to bring the Go programming language to micro-controllers and modern web browsers by creating a new compiler based on LLVM.
We can look at it as an “extension” to Go, as it still needs the original Go installation, but allows you to compile almost the same code to a MUCH smaller binary.

On a talk that Ron Evans (one of the creators of the project) gave, he demonstrates how a simple “Hello World” Go code can be compiled into a less than 1% (!!) binary comparing to the original binary created by a go build command.

1148709 vs 12376

Those capabilities and others, allow us to flash our almost identical code on tiny microcontrollers like Arduino Uno (which has 32KB of memory) and became an embedded developer in a few minutes.

The project is notably active and supports the most common boards out there.
On a well-known boards, like the Uno, the project provides almost full support for interfaces like GPIO and UART.

After a quick installation, you can start to write your code and communicate with the different components in the Arduino universe.

Finding a project

I always liked to play with boards like Arduino and Raspberry Pi, and the combination of them with the Go language sounds amazing to me.
So, as expected, I pulled my million-piece Arduino kit, installed everything that I need and started to play with TinyGo.

I started with tiny projects like mimicking a police car lights with the board, 2 LED lights, and 2 resistors –


Using a few lines of code I managed to communicate with the LED lights and to create it –

Next, I decided to connect my board to a Buzzer, which is supported of course, and to play some music!

Piezo Buzzer Interfacing With Arduino UNO Tutorial | Maxphi Lab

Don’t you think it’s cool? – and what about Doom or GOT theme songs?

The real challange

After I finished learning the basics I started to search for a bigger project.
For a long time I wanted to build a feeding system for my dog – not something too complicated, but something that will be controlled via Email or a command. No doubt that it can be useful.

A short Google search revealed a good and inspiring project.

Unfortunately, the motor that I got with the kit is unsupported by the project drives and I couldn’t make it work with it.
So the only thing I have to do now is to wait for my new motor to arrive by mail (it’s COVID-19 days after all).

This is the first post of mine about TinyGo. I hope that I could proceed with the project soon enough and log the process in this blog.

Stay tuned.

Leave a Reply

Your email address will not be published. Required fields are marked *