Go language on Raspberry Pi

24 Sep 2013

Prerequisites

Install

Note that you can install pre-built packages here: http://dave.cheney.net/unofficial-arm-tarballs

Install go 1.5 using Go Version Manager:

$ bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
$ source /home/pi/.gvm/scripts/gvm
$ sudo apt-get install bison
$ gvm install go1.4
$ gvm use go1.4
$ gvm install go1.5
$ gvm use go1.5 --default

Test

Create a file named hello.go and put the following code in it:

package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}

Then run it with the go tool:

$ go run hello.go

External References