This is a creation in Article, where the information may have evolved or changed.
Reference official website: https://golang.org/doc/install?download=go1.6.2.linux-amd64.tar.gz
Go Install File: https://golang.org/dl/
Linux installation files: https://golang.org/doc/install?download=go1.6.2.linux-amd64.tar.gz
To download the installation file:
Run: Get https://golang.org/doc/install?download=go1.6.2.linux-amd64.tar.gz
Unzip the file:
Run: tar-c/usr/local-xzf go1.6.2.linux-amd64.tar.gz
Set System environment variables:
Operation: Export Goroot=/usr/local/go
Operation: Export path= $PATH: $GOROOT/bin
Operation:export gopath= $HOME/Gopath
environment variable say name:
A. Adding a system variable Goroot:go installation directory
B. Modify the environment variable path: Add%goroot%\bin to the environment variable path, so that you can run the%goroot%\bin directory program directly in the DOS command mode, such as: Go.exe Godoc.exe
C. Add system variable Gopath:gopath is an important variable to set the package load path. You can set multiple paths, separated by semicolons (;).
Note: The source code of the package to be loaded must be placed in the SRC directory under the Gopath path, or the package will not be loaded
Running an instance:
创建文件夹
$HOME/gopath/src/hello
$HOME/ Gopath /src Add File hello.go under directory
Package Mainimport "FMT" Func Main () { fmt. Printf ("Hello, world\n")}
Compile:
Run: Go Install Hello
Perform:
Run: $GOPATH/bin/hello
Show: Hello, World