This is a creation in Article, where the information may have evolved or changed.
Introduction to the development of Go language programming: Go language is a new system-level language developed by Google, Project home: http://golang.org/
1. Install the Go Language environment
The go language is used primarily for Linux environments and provides source code installation. For a complete description of the relationship installation, please refer to
Official website: http://golang.org/doc/install.html.
The documentation here is primarily for users of Linux systems. Go uses mercurial management code, so it needs to be installed now
Mercurial tools. In addition, the go compiler relies on the following tools: Bison/gcc/libc6-dev/ed/gawk
and make.
Create an empty directory first, assuming that the $HOME/go, you can get the source code with the following command:
Code: Select All
$ HG clone-r release https://go.googlecode.com/hg/$HOME/go
Then configure the environment variables:
code: Select all
export goroot= $HOME/go
export goarch=386
export goos=linux
export gobin= $HOME/bin
gobin corresponds to the directory that the Go compiler tool places, to ensure that the corresponding directory exists. Then add the Gobin directory to path:
Code: Select All
Export path= $GOBIN: $PATH
Use the following command to see if the environment variable is already set:
Code: Select All
$ env | grep ' ^go '
If everything is ready, you can start compiling the go:
Code: Select All
$ cd $GOROOT/SRC
$./all.bash
If the compilation succeeds, you can see the following end information:
Code: Select All
-CD. /test
N known bugs; 0 Unexpected bugs
After the compilation succeeds, you can try the Godoc command if it is available.
2. Hello, World
Let's take a look at what the classic "Hello, World" program looks like in go:
Code: Select All
Package Main
Func Main () {
Print ("Hello, World \ n")
}
Save to the Hello.go file and compile with the following command:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.