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

Windowsgo1.4.windows-amd64.msiLinuxgo1.4.linux-amd64.tar.gzMacgo1.4.darwin-amd64-osx10.8.pkgFreeBSDgo1.4 .freebsd-amd64.tar.gz##UNIX/Linux/Mac OS X, and FreeBSD installationThe 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. 2. Unzip the downloaded source code package to the /usr/local directory.
tar -C /usr/local -xzf go1.4.linux-amd64.tar.gz
golist.jpg3. 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 system

You 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 Test

Create 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!