Go language environment installation
Go language supports the following systems:
Linux
- ##FreeBSD
- Mac OS . The package name corresponding to each system:
- Operating system
Package name
Linux | |
---|---|
Mac | |
FreeBSD | |
The following describes the installation Use the source code installation method under UNIX/Linux/Mac OS X, and FreeBSD systems: | 1. Download the source code package: go1.4.linux-amd64.tar.gz. |
tar -C /usr/local -xzf go1.4.linux-amd64.tar.gz3. Add the /usr/local/go/bin directory to the PATH environment variable:
export PATH=$PATH:/usr/local/go/bin
Note: Under the MAC system, you can use the installation package ending with .pkg to double-click it directly. Installation, the installation directory is under /usr/local/go/.
Installation under Windows systemYou can use the .msi suffix under Windows (the file can be found in the download list, such as go1.4.2.windows-amd64.msi) installation package to install. By default, the .msi file will be installed in the c:\Go directory. You can add the c:\Go\bin directory to your PATH environment variable. After adding it, you need to restart the command window for it to take effect. Installation TestCreate the working directory C:\>Go_WorkSpace.File name: test.go, the code is as follows:
package main import "fmt" func main() { fmt.Println("Hello, World!") }
Use the go command to execute the above code and the output result is as follows:
C:\Go_WorkSpace>go run test.go Hello, World!