Take the Ubuntu wiki installation tutorial as an example:
- Install the GCC tool, because golang some of the features are written in C, so building a Golang compilation is a must
$ sudo apt-get install Bison gawk gcc Libc6-dev make
- Install the mercurial tool to use the HG command to extract the source code of the Golang
$ sudo apt-get install mercurial
- Pick and extract, if your network speed is slow, this step will take a little more time
$ HG Clone-r Release Https://go.googlecode.com/hg/go
After decompression, enter the directory, compile Golang
$ cd go/src$./all.bash
It was supposed to be all right, but I got stuck there when I Checking API compatibility. Studied what the next Run.bash actually did, the original
Attempting to use the previously installed Hg tool, also known as mercurial, did a version check ... All right, just delete him ...
$ sudo apt-get remove mercuial
It's all in the local operation, and there's no problem.
If a message appears, the installation is successful
All TESTS PASSED---installed Go for linux/amd64 In/home/you/go. Installed commands in/home/you/go/bin.*** you need to Add/home/you/go/bin to your $PATH. The compiler is 6g.
$GOBIN Golang Bin directory, here is ~/go/bin here is a configuration example: please pay special attention to the configuration of $goos and $GOARCH
$ vim ~/.BASHRC
Then join
Export Goroot=~/goexport goarch=386/amd64export goos=linuxexport gobin= $GOROOT/bin/export gotools= $GOROOT/pkg/tool/ Linux_amd64/export path= $PATH: $GOBIN: $GOTOOLS
SOURCE ~/.BASHRC
- Create a new hello.go, and write the following:
Package Mainimport "FMT" Func Main () {FMT. Printf ("Hello, world\n")}
- Using the Golang official website compiler (' Note: ' 6g is the go compiler for AMD64, it generates a. 6 file. Instead, 3,861 uses the 8g command, which typically generates. 8 formatted files. Of course there is a 5g command is used for ARM CPU, the same AMD64 with 6l,386 with the 8l,arm with 5L Linker! )
$6g hello.go$ 6l hello.6$./6.outhello, World
Ubuntu 14.10 Compilation installation Golang