Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Go language environment installation


May 11, 2021 Go


Table of contents


Go language environment installation

The Go language supports the following systems:

  • Linux
  • Freebsd
  • Mac OS X (also known as Darwin)
  • Window

The installation package download address is: https://golang.google.cn/dl/.

The package name for each system:

Operating system The name of the package
Windows go1.15.2.windows-amd64.msi
Linux go1.15.2.linux-amd64.tar.gz
Mac go1.15.2.darwin-amd64.pkg
Source go1.15.2.src.tar.gz

UNIX/Linux/Mac OS X, and FreeBSD installations

Here's how to install using source code under UNIX/Linux/Mac OS X, and FreeBSD systems:

1, download the source package: go1.15.2.linux-amd64.tar.gz.

2. Unzip the downloaded source package to the /usr/local directory.

tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz

3. Add the /usr/local/go/bin directory to the PATH environment variable:

export PATH=$PATH:/usr/local/go/bin

4, verify whether the installation of successful commands:

$ go version

Note: Under MAC, you can use the installation package at the end of .pkg to double-click directly to complete the installation, the installation directory is under /usr/local/go/, and the installation path /usr/local/go/bin is configured into a variable environment.


Installed under the Windows system

Windows can be installed using an installation package with the .msi suffix, which can be found in the download list, such as go1.4.2.windows-amd64.msi.

By .msi files are installed in the c:\Go directory. Y ou can add the c:\Go\bin directory to the PATH environment variable. After you add, you need to restart the command window to take effect.

Install the test

Create a working directory, C:\gt;Go_WorkSpace.

File name: test.go, code as follows:

package main

import "fmt"

func main() {
   fmt.Println("Hello, World!")
}

Use the go command to execute the above code output as follows:

C:\Go_WorkSpace>go run test.go

Hello, World!