Install the Go tools
Windows
The Go project provides two installation options for Windows users : a zip archive that requires you to set some environment variables and an MSI installer that configures your installation automatically.(推荐使用MSI安装包会自动配置环境变量)
MSI installer
c:\Go
c:\Go\binPATH
Linux
/usr/local/usr/local/go
tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
sudo
/usr/local/go/binPATH/etc/profile$HOME/.profile
export PATH=$PATH:/usr/local/go/bin
Test your installation
Check that Go is installed correctly by setting up a workspace and building a simple program, as follows.
%USERPROFILE%\goGOPATH
src\hellohello.go
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
go
C:\> cd %USERPROFILE%\go\src\hello
C:\Users\Gopher\go\src\hello> go build
go run hello.go
hello.exe
参考资料: