1. Introduction
Go is a nice language started by Google. A nice advantage is that it compiles to native code and the binary does not have additional dependencies. Performance and low resource usage are focused on, even though I personally don't like the gargabe collection based memory cleanup.Go brings very good documentation (godoc for accessing it), and it enforces a well defined code formatting (gofmt).
Even for Emacs the supporting tools are great, including very good code completion and documentation access which makes it nice to develop in Go.
The compiler itself used to be very fast (in Go 1.4) but got somewhat slower in newer version. But it is still fast enough in contrast to other language, especially since it can build whole project without additional tools.
Finally, it is easy to include third-party projects with "go get" which downloads packages and stores them locally (which you might want to store in case the remote repository is longer available in a year or so).
2. Installation
Since Go version 1.5 you need Go itself to compile it. So we first start with Go 1.4:- Download it from https://golang.org/doc/install/source?download=go1.4.3.src.tar.gz
- Untar it, let's assume the directory is DIR14
- cd to "DIR14/src"
- Build Go 1.4 with:
./all.bash
- Download Go 1.6 from https://golang.org/doc/install/source?download=go1.6.2.src.tar.gz
- Untar to DIR16, let's assume the directory is DIR16
- cd to "DIR16/src"
- Tell Go where to find the Go compiler to bootstrap with:
export GOROOT_BOOTSTRAP=DIR14
- Now build Go 1.6 with :
./all.bash
- Set the root of the Go installation:
export GOROOT=DIR16
- Tell go where to store additional packages downloaded with "go get":
export GOPATH=<path/to/addons>
- And finally add the bin directory to your PATH:
export PATH=$PATH:$GOROOT/bin
go get golang.org/x/tools/cmd/godocor install all tools with
go get golang.org/x/tools/cmd/...
3. Test compiler
- Create a file "hello.go" with content
package main import "fmt" func main() { fmt.Println("Hello World") }
- Compile with
go build hello.go
- Run with
./hello