Build Go Programs for Raspberry Pi

I tend to do cross compiling with Go >=1.5, so I don’t have to build Go on Raspberry Pi, which is slow.

GOOS=linux GOARCH=arm GOARM=6 go build -a

Please remember to use -a to avoid cached built packages.

Also, please remember to set the correct GOARM version. To get the ARM version, you can run

cat /proc/cpuinfo

On my Raspberry Pi, it outputs

yi@raspberrypi:~ $ cat /proc/cpuinfo
processor	: 0
model name	: ARMv6-compatible processor rev 7 (v6l)
BogoMIPS	: 2.00
Features	: half thumb fastmult vfp edsp java tls 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xb76
CPU revision	: 7

Hardware	: BCM2708
Revision	: 000e
Serial		: 00000000cd23b897

The line model name : ARMv6-compatible processor rev 7 (v6l) tells that it is ARMv6, so I set GOARM=6.