golang Development :( ii) installation Golang

Mac installation

Access Download , Download go1.12.5.darwin-amd64.pkg, double-click the downloaded file, click Next all the way to the default installation, this time to go already installed on your system, the default has increased corresponding ~ / go in PATH / bin, this time to open a terminal, enter go

See the source code similar to the above caption successful installation has been successfully installed

If you go Usage information appears, then that has been installed successfully go; if there is the command does not exist, you can check your PATH environment variable contains the go in the installation directory.

Linux installation

Access Download , Download go1.12.5.linux-amd64.tar.gz,

Assume that the directory you want to install Go for $ GO_INSTALL_DIR, later replaced by the corresponding directory path.

Decompress tar.gz package to the installation directory: tar zxvf go1.12.5.linux-amd64.tar.gz -C $ GO_INSTALL_DIR.

设置PATH,export PATH=$PATH:$GO_INSTALL_DIR/go/bin

And then do go

Windows Installation

Access Download , Download go1.12.5.windows-amd64.msi. After downloading run good, do not modify the default installation directory C: \ Go, if installed to other locations will lead to not execute their own code Go written. After the installation is complete will be added after the default environment variable Path bin directory under C Go installation directory: \ Go \ bin, and add the environment variable GOROOT, the value of Go install root C: \ Go.

Verify that the installation was successful

Enter cmd in the Run to open a command-line tool, enter go at the prompt, check to see Usage information. Enter cd% GOROOT%, Go see if you can enter the installation directory. If both succeed, the installation was successful.

Not, then check the value of the environment variable Path and GOROOT of. After the uninstall if there reinstalling the presence restart the computer to retry the above steps.

golang source installation

Go 1.5 complete removal of C code, Runtime, Compiler, Linker written by Go realize bootstrap. Only on a version installed, you can install from source. Therefore, you must first install the previous version 1.5, and then install the later version.
Before Go 1.5, Go source code, some parts with Plan 9 C and AT & T compilation of writing, so if you want to install from source, you must install the C compiler tools.
On a Mac, as long as you have installed Xcode, it already contains the appropriate compiler tools.
In Unix-based systems, and the like need to install gcc tools. The system may be performed by e.g. Ubuntu sudo apt-get install gcc libc6- dev in the terminal to install the compilation tools.
On Windows systems, you need to install MinGW, then install MinGW gcc, and set the appropriate environment variables.
You can download the source code to find the corresponding Source go1.12.5.src.tar.gz file download, unzip to $ HOME directory Once downloaded, execute the following code:

cd go/src
./all.bash

When "ALL TESTS PASSED" words appear after running all.bash considered successful installation.

The above is a Unix-style command, similar to the installation under Windows, just run all.bat, call the compiler is MinGW's gcc.

If a window system, you need to set environment variables, add the directory corresponding go where the path inside, set gopath variables.

Set the path of golang

Edit ~ / .zshrc

//golang安装目录,bin目录
export GOROOT=/usr/local/go
//golang项目目录
export GOPATH=/Users/XX/www/go
//golang编译结果生成目录
export GOBIN=/Users/XX/www/go/bin

mkdir /Users/XX/www/go/{src,pkg,bin}
source ~/.zshrc

Guess you like

Origin www.cnblogs.com/golangcode/p/10927147.html
Recommended