Cross compiling Go for Checkpoint 1100

I quickly tested Go cross compilation of simple web server to Checkpoint 1100 appliance which is running on ‘arm’ CPU.

[Expert@Irek-11]# uname -a
Linux Irek-11 2.6.22.18 #1 Wed May 13 16:24:38 IDT 2015 armv5tejl arm
[Expert@Irek-11]# ifconfig br0 | grep inet
 inet addr:10.199.107.1 Bcast:10.199.107.127 Mask:255.255.255.128

Using Go I can cross compile to arm processor architecture on any Linux or even Windows machine, just by specifying set GOOS and GOARCH to be the values for the target operating system and architecture. No need to install Go compiler on Checkpoint 1100 in this case. So on my regular Linux I have Go program main.go for web server on port 8888 which is taking uri path argument to display hello like message:

$ cat main.go 
package main
import (
 “fmt”
 “net/http”
)
func handler(w http.ResponseWriter, r *http.Request) {
 fmt.Fprintf(w, “Hi there, I love %s!”, r.URL.Path[1:])
}
func main() {
 http.HandleFunc(“/”, handler)
 http.ListenAndServe(“0.0.0.0:8888”, nil)
}

I cross compile source main.go to arm binary on my regular Linux (and rename later to simpleweb.arm)

$ env GOOS=linux GOARCH=arm go build main.go

and it shows as statically linked arm binary

$file simpleweb.arm
main: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped

then I transfer it to Checkpoint 1100 and run it:

ftp> get simpleweb.arm
local: simpleweb.arm remote: simpleweb.arm
200 PORT command successful.
125 Data connection already open; Transfer starting.
226 Transfer complete.
4968183 bytes received in 2.25 secs (2.2e+03 Kbytes/sec)
ftp> quit
221 Goodbye.
[Expert@Irek-11]# chmod +x simpleweb.arm
[Expert@Irek-11]# ls -lh simpleweb.arm 
-rwxr-xr-x 1 root root 4.7M Feb 24 11:15 simpleweb.arm
[Expert@Irek-11]# ./simpleweb.arm

Last thing to do is just to open the page from my PC , typing url with address of Checkpoint 1100 appliance i.e. http://10.199.107.1:8888/go

Go web server running on Checkpoint 1100 with ARM CPU
Show your support

Clapping shows how much you appreciated Irek Romaniuk’s story.