1, C language Tools Go tool chain is written in C language, build needs to install the following development tools: GCC, C language standard library, Bison, make, awk and so on. For Ubuntu/debian systems, run the Install command: sudo apt-get install bison ed gawk gcc Libc6-dev make
2. Installation Mercurial
You need to install the Mercurial version management system (you can output HG name detection for installation) before you do the following. Install enter the following command:
sudo easy_install mercurial
For Ubuntu/debian Systems, the Easy_install command can be used
Apt-get Install Python-setuptools Python-dev build-essential
Installation.
If the above command fails, you can also download it from Mercurial Download.
3, get the code
The following command creates a go directory. Switch to the appropriate directory and make sure that no go directory exists at the current location, running the command:
HG Clone-r Release Https://go.googlecode.com/hg/go
It's not usually routed to Google.
So you can click on the open link to download go1.3.3.src.tar.gz
4, add the go1.3.3.src.tar.gz to the Ubuntu under the decompression
root@ubuntu:~# tar-zxf go1.3.3.src.tar.gz
root@ubuntu:~# ls
1.txt go go1.3.3.src.tar.gz Yankring_history_v2.txt
You'll see one more go file under the current directory.
5. Install Go
CD go/src
./all.bash
Post-compile End information:
All TESTS passed---installed go forlinux/amd64in/home/calvin/go installed commands * * * you In/home/calvin/go/bin To Add/home/calvin/go/binto your PATH.
6. Configure Environment variables
Mkdir/usr/local/go
CP -RP bin Doc include/lib//usr/local/go/
vi/etc/profile
Plus:
Export path= $PATH:/usr/local/go/bin
export goroot= $HOME/lnk
So you can compile the go file directly under Home/lnk.
7, testing
root@ubuntu:/home/lnk/restgo# vi hello.go
root@ubuntu:/home/lnk/restgo#
root@ubuntu:/home/lnk/restgo#
root@ubuntu:/home/lnk/restgo# go run hello.go
Hello, the world
----------------------------------------------------
Test go, the classic Hello World
Hello.go File Contents:
root@ubuntu:/home/lnk/restgo# Cat Hello.go
Package main
Import "FMT"
func Main () {
fmt. Printf ("Hello, world\n")
}