This is a creation in Article, where the information may have evolved or changed.
Windows Installation Go language development environment
- Download the installation package
Download Address:Http://www.golangtc.com/download
32-bit Please select the MSI installation package that contains windows-386 in the name, 64-bit Select the name that contains WINDOWS-AMD64. After downloading, do not modify the default installation directory C:\Go\, if installed to another location will cause you can not execute their own written Go code. After the installation is complete, the environment variable Path is added to the bin directory under the Go installation directory C:\Go\bin\, and the environment variable goroot is added, and the value is C:\Go\ for the Go installation root directory.
Verify that the installation is successful
Enter CMD in the run to open the command-line tool, enter go at the prompt to check if you can see the Usage information. Enter the CD%goroot% to see if you can go to the Go installation directory. If successful, the installation is successful.
If not, check the values of the above environment variables Path and goroot. If not present please reinstall after uninstalling, exists please restart the computer and retry the above steps.
environment variable Settings
The go compiler requires three required environment variables and an optional environment variable. Environment variables are set in. bashrc or other configuration files.
GOPATH=C:\GO;C:\GO\SRC; F:\Go\Demo
$GOROOT
The root directory of the go installation package. It is usually placed in a $home/go, and of course it can be another location. Default is C:\go
$GOOS and and $GOARCH
These two environment variables represent the operating system and CPU type of the target code. $GOOS options are Linux, FreeBSD, Darwin (Mac OS X 10.5 or 10.6) and NaCl (Chrome's Native Client interface, not yet complete). $GOARCH options are AMD64 (64-bit x86, currently the most mature), 386 (32-bit x86), and arm (32-bit arm, not yet completed). The following are possible combinations of $goos and $GOARCH:
my: Goos=darwin goarch=amd64
$GOOS $GOARCH Darwin 386 Darwin AMD64 FreeBSD 386 FreeBSD amd64 Linux 386 linux amd64 linux arm incomplete NaCl 386 Windows 386 Incomplete
$GOBIN (optional) (optional)
C:\go\bin; F:\Go\Demo\bin; The following is the working directory
Indicates the binary directory used to store go. If the $GOBIN environment variable is not set, it is installed in $home/bin by default. If you set this variable, you need to make sure that the $path variable also contains the path so that the compiler can find the correct execution file.
$GOARM (optional, arm, default=6)
ARM processor (to be supplemented).
It should be noted that the $goarch and $goos environment variables represent the target Code runtime environment, which is irrelevant to the platform currently in use. This is convenient for cross-compiling. Set the following environment variables in the. bashrc file:
Export goroot= $HOME/go export GOARCH=AMD64 export goos=linux export path=.: $PATH: $GOBIN
Check to see if it works:
SOURCE ~/.BASHRC CD ~ 8g-v
Go Configuration Error: Gopath entry is relative; Must be absolute path: "".
E:\GOPATH the value of the Gopath; Changed to E:\GOPATH unexpectedly good, originally is the end semicolon mischief.