This is a creation in Article, where the information may have evolved or changed.
A detailed introduction to the development environment of go language can be found on the official Go website. The URL is: http://golang.org/doc/install.html, its Chinese translation here: Http://code.google.com/p/golang-china/wiki/Install.
The official go language is not currently supported by the Windows operating system, so the official installation introduction is for the Unix/linux system. However, there are geek for the Windows transplant, can be downloaded here to: http://code.google.com/p/gomingw/downloads/list, download the installation package all the way next installation is OK, the default installation in the C:\Go folder. subdirectory Doc also has a lot of go language information.
Here's a brief introduction to the most basic steps on Unix/linux, which allows go to run as quickly as possible:
(1). Install the C language tool
Go's toolchain is written in C and builds the development tools needed to install GCC, libc, bison, make, awk, ed.
For OS X systems, the above tools are part of Xcode.
For the Ubuntu/debian system, run the Install command:
$ sudo apt-get install bison ed gawk gcc libc6-dev make
for the Redhat/centos system, run the Install command:
$ sudo yum install bison ed gawk gcc libc6-dev make
(2). Install Mercurial Distributed version management tool
Go now uses mercurial to manage the project and install it to get the latest source of go. Install Easy_install before installing, and then install mercurial.
For the Ubuntu/debian system, run the Install command:
$ sudo apt-get install python-setuptools python-dev build-essential
for Redhat/centos, run the Install command:
$ sudo yum install python-setuptools python-devel build-essential
Now you can install mercurial, run the Install command:
$ sudo easy_install mercurial
(3). Get Go Code
Get the code, usually in your own home directory, run
$ hg clone -r release https://go.googlecode.com/hg/ go
so the $home/go folder below is the go source.
(4). Compile and install Go
Compiling the installation is also very simple, just execute a prepared script to run the command:
$ cd go/src; ./all.bash
when the compilation is complete, some information is printed to indicate where the test case passed, the current OS, the architecture, and the Go installation location.
ALL TESTS PASSED---Installed Go for linux/amd64 in /home/you/go.Installed commands in /home/you/go/bin.*** You need to add /home/you/go/bin to your $PATH. ***
(5). Add the GO environment variable:
Go's recommended installation location is/usr/local/go, of course you can also install in other locations, such as $home below. Go is required to set a GOPATH environment variable to represent the path of your workspace after the official version. It is also best to set a goroot environment variable to indicate where go is installed.
Set the following environment variables in the $HOME/.BASHRC file (or other configuration file such as/etc/profile, $HOME/.profile, etc.):
Export Goroot=/usr/local/go
Export Gopath=/path/to/workspace
Export path= $PATH/bin: $GOROOT/bin: $GOPATH/bin
Run the source ~/.BASHRC load environment variable
(6). Go code compile Run
Go requires that your workspace be made up of 3 sub-folders, SRC, pkg, and bin. SRC below is the folder where the package is organized. The last layer of the path is treated as the package name. Go write lib or exe is compiled with a unified go Install command, run in the form of:
[Plain]View Plaincopy
- Go install/path/to/package
Since you have added $gopath/bin to the $path, you can run the EXE in the bin under workspace directly from anywhere.
Original: http://blog.csdn.net/archimedes_zht/article/details/7062181