This is a creation in Article, where the information may have evolved or changed.
First open the Install Go page: http://golang.org/doc/install.html
Follow the wizard to install it step-by-step.
My environment: Ubuntu9.10,acer Aspire4710 32-bit machine
The following "#" indicates the description text, the rest is the command in the terminal or the file operation
1.Environment variables (environment variable setting)
(1) CD
(2) mkdir go
(3) MkDir bin
(4) Vi. BASHRC
(5) #在文件最后添加如下内容 (depending on the machine, different GOOS and goarch settings are used, generally Linux and 386, most of which are used in many of these two):
Export goroot= $HOME/go
Export Goos=linux
Export goarch=386
Export gobin= $HOME/bin
#然后执行: Wq Save File
(6) source. BASHRC
(7) Sudo/etc/profile
(8) #在文件最后修改PATH, path does not exist, add the following statement directly, otherwise add $home/bin
Export path= $HOME/bin: $PATH
#然后执行: Wq Save File
(9) Source/etc/profile
(#执行env) | grep ' ^go ' tests whether the GO environment variable has been set correctly
2. Get some of the resources you need to go
(1) #一般来说都没有安装mercurial (source control management (SCM), online direct check mercurial)
#在ubuntu里执行的是 (unlike the sudo easy_install mercurial, which differs from the official web)
sudo apt-get install mercurial
(2) #保证 $GOROOT does not exist, or it is empty.
HG Clone-r release HTTPS://GO.GOOGLECODE.COM/HG &goroot
3. Install Go
(1) #安装必要的软件 (installed part in ubuntu9.10
sudo apt-get install bison gcc Libc6-dev ed
(2) CD $GOROOT/SRC
(3)./all.bash
#执行时间较长, the normal words on the official website, the final should be prompted---CD. /test
#N known bugs; 0unexpected bugs
#但我遇到了一些问题, but does not affect the use of later, I hope to have a master to help solve this problem, the final error is as follows:
#make [2]: Leaving directory '/home/chenhaiyu/go/src/pkg/http '
#---Fail:http. TestClient
# Get http://www.google.com/robots.txt:unexpected EOF
#---Fail:http. Testredirect
# Get http://codesearch.google.com/: Unexpected EOF
#FAIL
#make [1]: * * * [Test] Error 1
#make [1]: Leaving directory '/home/chenhaiyu/go/src/pkg/http '
#make: * * [Http.test] Error 2
4. Write an example on the official website (64-bit system, I use Linux 386, so 8, different from 6, the example runs successfully
(1) CD
(2) mkdir Hellogo
(3) CD Hellogo
(5) Cat >hello.go <<eof
Package Main
Import "FMT"
Func Main () {
Fmt. Printf ("Hello, world\n"
}
Eof
(6) 8g Hello.go
(7) 8l Hello.8
(8)./8.out
Hello, world
5. Go language and environment to complete the completion, hurriedly to see the official Internet Café http://golang.org/, which has documents, programming, help and other catalogs, are very helpful for beginners.
Of course, you also refer to the directory under the $goroot, there is a lot of information, a preliminary look at
(1). doc directory, the official Web reference document, but did not see index.html, can only one point, such as: Install.html is the installation of boot, etc.
(2). Include is some header files, played C's friends are very clear what this means, like libc.h inside is mainly some structure, pointers and other definitions
(3). lib package contains a few. A end of the package files, should belong to the class library, go runtime should be trusted in these class library
(4). Misc Directory is a number of miscellaneous things, it is estimated that the development of the use of some of the methods used in the library, etc., currently no need to care
(5). Pkg, here contains a lot of. A package files, but do not know where the official API documentation can be referenced, with these library files can provide a lot of API can call
(6). src directory, no need to say more, of course, the source folder
(7). Test directory contains a lot of testing examples, of course, also includes our practice of helloworld.go, through these test examples, can quickly improve your familiarity with the go language
6. Summing up, the development of a new language is indeed a very difficult thing, not only the old language functions must have, but also to add their own new features, of course, the go language just started, but a see it can be fused with Flex, Java, C, C + + and other language features, so-called synthesizer, Of course, I hope go does not lose the advantages of other languages in order to go better.