Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Go Language Environment Installation

Go Language Environment Installation

Go supports the following operating systems:

The installation package download address is:https://go.dev/dl/。

If you cannot open it, you can use this address:https://golang.google.cn/dl/。

The package names corresponding to each system are:

Installation package filename Supported Systems Processor architecture System version requirement Description
go1.26.3.windows-amd64.msi Microsoft Windows x86-64 (Intel 64-bit) Windows 10 or later Graphical installer for 64-bit Windows systems
go1.26.3.darwin-arm64.pkg Apple macOS ARM64 (Apple Silicon 64-bit) macOS 12 or later Installer for Macs with M-series chips (including your Mac mini 4)
go1.26.3.darwin-amd64.pkg Apple macOS x86-64 (Intel 64-bit) macOS 12 or later For older Macs with Intel processors
go1.26.3.linux-amd64.tar.gz Linux x86-64 (Intel 64-bit) Linux 3.2 or later Archive for the vast majority of 64-bit Linux systems
go1.26.3.src.tar.gz Any system Source code - Go source code package, which must be compiled manually

Installation on UNIX/Linux/Mac OS X, and FreeBSD

The following describes how to install from source on UNIX/Linux/Mac OS X, and FreeBSD systems:

1. Download the binary package: go1.4.linux-amd64.tar.gz.

2. Extract the downloaded binary package to the /usr/local directory.

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

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



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

The above only adds PATH temporarily; it is gone after you close the terminal and log in again next time.

We can edit ~/.bash_profile or /etc/profile and append the following command to the end of the file, making it permanent:



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

After adding, you need to run:

source ~/.bash_profile

或

source /etc/profile

Note:On macOS you can use a .pkg package ending in .pkg by double-clicking to complete the installation; the installation directory is /usr/local/go/ the following directory.


Installation on Windows

On Windows you can install using a package with the .msi extension (found in the download list, e.g., go1.4.2.windows-amd64.msi).

By default .msi The files will be installed in the c:\Go directory. You can add the c:\Go\bin directory to the Path environment variable. After adding, you need to restart the command window for it to take effect.

Installation test

Create a working directory C:>Go_WorkSpace。

Code for the test.go file:

package

main

import

"fmt"

func

main

()

{

   fmt

.

Println

(

"Hello, World!"

)

}

Running the above code with the go command produces the following output:



C:\Go_WorkSpace>go run test.go



Hello, World!