This is a creation in Article, where the information may have evolved or changed.
First of all
Read Https://github.com/astaxie/build-web-application-with-golang/blob/master/1.1.md
Read Http://code.google.com/p/golang-china/wiki/Install at the same time
To download go1.0.3.linux-amd64.tar.gz, execute the following command sequentially:
sudo mkdir/opt/google
sudo tar zxvf go1.0.3.linux-amd64.tar.gz-c/opt/google
VI ~/.BASHRC
Join
Export Gopath= $HOME/go
Export Goroot=/opt/google/go
Export GOARCH=AMD64
Export Goos=linux
Export path= $PATH: $GOPATH/bin: $GOROOT/bin;
Save
SOURCE ~/.BASHRC
Proceed to go, success
Then read on.
Https://github.com/astaxie/build-web-application-with-golang/blob/master/1.2.md
CD ~
mkdir Go
CD Go
mkdir SRC
CD src
mkdir Hello
CD Hello
VI Hello.go, the contents are as follows:
Package Mainimport "FMT" Func Main () { fmt. Println ("Hello world.\n")}
Save, go to install Now
You will find that the following files are automatically generated
$HOME/go/bin/hello
There is still only one hello.go file under the current folder ($/home/go/src/hello/)
But because $home/go/bin has been added to the path variable
So just run hello and you can play Hello world.
Attention:
Gopath Point to your working folder
goroot The installation directory pointing to Golang
Go build generates executable files in the current directory
Go install generate executable file in Bin directory