First Open Install Go page: http://golang.org/doc/install.html
Follow the wizard step-by-step to install.
My environment: Ubuntu9.10,acer Aspire4710 32-bit machine
The following "#" indicates the text, and the rest is the command or file operation in the terminal
1.Environment variables (environment variable settings)
(1) CD
(2) mkdir go
(3) MkDir bin
(4) Vi. BASHRC
(5) #在文件最后添加如下内容 (depending on the machine to use different GOOS and goarch settings, generally for Linux and 386, most of them still use more than 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
(a) #执行env | grep ' ^go ' tests if the GO environment variable is set correctly
2. Get some resources to go
(1) #一般来说都没有安装mercurial (source Code control management (SCM), online directly check mercurial)
#在ubuntu里执行的是 (different from the mercurial of the official web, sudo easy_install)
sudo apt-get install mercurial
(2) #保证 $GOROOT does not exist or is this empty
HG Clone-r release HTTPS://GO.GOOGLECODE.COM/HG &goroot
3. Install Go
(1) #安装必要的软件 (installed parts in ubuntu9.10)
sudo apt-get install bison gcc Libc6-dev ed
(2) CD $GOROOT/SRC
(3)./all.bash
#执行时间较长, the normal word on the official web, 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 last 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. According to the official online writing example (the official website is a 64-bit system, I use Linux 386, so use 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. The go language and environment to complete, hurriedly to see the official Internet Café http://golang.org/, which has documents, programming, help and other directories, are very helpful for beginners information.
Of course, you also refer to the $goroot under the directory, there are a lot of information, a preliminary look at
(1). doc Directory, official online reference documents, but did not see index.html, can only one point, such as: Install.html is the installation guide and so on
(2). Include some header files, friends who have played C very clear what this means, like libc.h inside is mainly some structure, pointers and other definitions
(3). lib package contains several. A end of the package file, should belong to the class library, go run should be trusted by these class libraries
(4). Misc Directory is a number of miscellaneous Dongdong, is estimated to be in the development of some of the methods used in the class library, etc., there is no need to care
(5). Pkg, which 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 APIs can call
(6). src directory, needless to say, of course, is the source folder
(7). The test directory contains a lot of testing examples, including, of course, the helloworld.go of our practice, with these test examples, you 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 functions of the old language must have, but also to add their own new features, of course, go language just started, but a see it can be integrated with the Flex, Java, C, C + + and other language features, the so-called synthesizer, Of course I hope go does not lose the advantages of other languages in order to walk better.