This is a creation in Article, where the information may have evolved or changed.
Introduction
The go language is an open source system-wide programming language based on the BSD release of Google, with the goal of fusing Python's development efficiency and C's run-time efficiency. The site of the project is http://golang.org. Currently only supports the AMD64 and 386 architectures of the Linux,freebsd and Mac OS x platforms.
Installation
There is a quick compiler installation instructions, see http://golang.org/doc/install.html. The installation process for my Ubuntu9.10 in the virtual machine is as follows:
1. Setting Environment variables
You need to set 4 variables altogether
Export goroot= $HOME/goexport goarch=386export goos=linuxexport gobin= $HOME/bin
If your platform is AMD64, replace Goarch with AMD64, and Gobin is optional and can
mkdir ~/bin
Here is the directory that holds the Go Language compiler connector, which needs to be added to path:
Path=${path}: $HOME/binCopy the above line and the above 4 export to your. BASHRC.
Reopen the terminal window.
2. Get Go Source
Go using C write, need to get the source code after compiling, at the command line to execute the following command:
apt-get Install python-setuptools python-devsudo easy_install mercurialhg clone-r release https:// go.googlecode.com/hg/$GOROOTsudo apt-get Install bison gcc libc6-dev ed makecd $GOROOT/srcmake All
Wait until it appears:
---CD. /testn known bugs; 0 Unexpected bugs
(n is a number, I am here for 4) after the compilation is complete.
Write Hello go!
For different architectures, the compiler and linker are not the same:
386 the corresponding compiler is 8g, the linker is 8l;
AMD64 the corresponding compiler is 6g, the linker is 6l;
OK. Let's write a simple go program with the following code:
Package Mainimport "FMT" Func Main () {FMT. Printf ("Hello, world/n")}
Save the above code as HELLO.GO and compile it:
8g Hello.go
Generate hello.8 after compiling, then link:
8l hello.8
Generate Hello.out, execute:
./hello.out
The terminal will display:
Hello, go!.
If you are writing a large program, the Make tool is still valid.
Grammar and Class library documentation
Syntax See here:
Http://golang.org/doc/go_spec.html
See the Class library here:
http://golang.org/pkg/
Useful Documentation:
Http://golang.org/doc/effective_go.html
Http://golang.org/doc/go_tutorial.html
If you have previously learned C + + can refer to here:
Http://golang.org/doc/go_for_cpp_programmers.html
Keep the latest version
At present, the go language is still being perfected, not to be able to enter the production environment, if you want to update the latest version, as follows:
HG PULLHG Update Releasemake all