Cross Compiling Go Code in Weird Configurations for fun and (little) profit
============================================================================
This represents my experiments in getting Go to do different configuration things for our cross-platform environment
Building Go code for Target (no mixed code, just Go)
----------------------------------------------------
```
nick@bignick:~/demo/targetMe$ GOOS=linux GOARCH=arm GOARM=5 go build
nick@bignick:~/demo/targetMe$ file targetMe
targetMe: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped
```
Building C code in to Go with cross compiler
--------------------------------------------
See also: https://github.com/golang/go/issues/12443#issuecomment-136906785 for useful information
```
nick@bignick:~/demo/$ CC=arm-poky-linux-gnueabi-gcc CGO_CFLAGS="-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi" CGO_LDFLAGS=-v CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=5 go build -o Foo_ARM *.go
```
Building Go code into C
-----------------------
```
nick@bignick:~/demo/cgodemo$ go build -buildmode=c-archive exportSyms.go
nick@bignick:~/demo/cgodemo$ gcc -pthread useFromC.c exportSyms.a -o useFromC
nick@bignick:~/demo/cgodemo$ ./useFromC
10
2015/09/02 14:22:13 Hello World
```
Cross Compiling Go into Library for Compiling into Target app
-------------------------------------------------------------
```
nick@bignick:~/demo/cgodemo$ CC=arm-poky-linux-gnueabi-gcc CGO_CFLAGS="-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/poky/1.7.1/sysroots/cortexa8hf-vfp-neon-poky-linux-gnueabi" CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=5 go build -buildmode=c-archive exportSyms.go
nick@bignick:~/demo/cgodemo$ $CC -pthread useFromC.c exportSyms.a -o useFromC
nick@bignick:~/demo/cgodemo$ file useFromC
useFromC: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=914408ad20be622e5205f93175e7c4d0337487e9, not stripped
nick@bignick:~/demo/cgodemo$ scp useFromC root@TARGET.local:/tmp/
...
root@TARGET:~# /tmp/useFromC
10
2015/05/30 01:46:31 Hello World
```