Skip to content

Go Language for Embedded ARM Linux Systems

In the quest for technologies that work well for embedded Linux systems, I recently gave Go another try.  The last time I tried this was very early on and there were some floating point issues on ARM that appear to be fixed now.  Having spent a few days porting an existing application to Go, there is a lot to like about Go.

  • Compiles very fast
  • Nice set of default libraries that are nice to use
  • Binaries are reasonable size
  • Memory usage is reasonable
  • Very simple to deploy (run time and libs are bundled with a single executable)
  • many 3rd party libraries available
  • Tooling is good (build, unit testing, etc)

As an example of running a Go app on an embedded Linux system, enter the following in hello.go:

package main
import (
func main() {

To run on x86:

go run Hello.go

To build for ARM Linux:

$ GOARCH=arm GOARM=5 go build hello.go
$ file hello
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped

As you can see, cross compiling is very easy with Go.

Now, to try this exe on a Raspberry PI 3 running Arch Linux:

[root@alarmpi ~]# ./hello
I did notice the time to build for ARM is a bit longer than building for x86:
$ time go build hello.go

real	0m0.262s
user	0m0.337s
sys	0m0.030s
$ time GOARCH=arm GOARM=5 go build hello.go
real	0m2.533s
user	0m4.930s
sys	0m0.183s
But, still pretty reasonable considering what all it is doing.  The simplicity of all this is very attractive.  There is no runtime to cross compile and deploy.  Just one executable and you’re good to Go.

1 thought on “Go Language for Embedded ARM Linux Systems”

  1. Interesting but too the tutorial is far to brief.
    Where re the go sourcesa located…
    I wil try this in a raspberry pi 2

Comments are closed.