Golang installing golang



I have made a brief introduction to the go language, and I believe you have basically understood it. Then I believe you can’t wait to learn the go language, but we need to install the go development environment before learning the go language.

The so-called environment installation is to install the instructions of go language on your computer, so you can use it directly when developing software. The installation of go environment is divided into the installation of windows system and the installation of Linux system.

Download address

Go language official website download address: https://golang.org/dl/

Go language mirror station: https://golang.google.cn/dl/

It is recommended to download executable files for windows and MAC platforms, and compressed files for Linux platforms

We choose the corresponding version according to our own operating system

Installing go under Windows

This installation is based on64 bit windows10System installationGo 1.13.4 executable versionFor example.

  1. Open the downloaded installation package

  1. clicknext, continue clickingnext

  1. Choose the installation directory of go language and try to choose something easier to remember(Do not appear Chinese in the installation path).

  1. Install

  1. Displaying this interface indicates that the installation is successful

  1. After installation, you can open the terminal window and entergo versionCommand to view the installed go version

Configure gopath

GOPATHIs an environment variable used to indicate the storage path of the go project you write

be careful: not the installation directory, but the working directory and the directory for writing code

GOPATHIt’s best to set only one path, and all project codes are placed inGOPATHofsrcUnder the directory

be careful: inGo 1.11After version, opengo modAfter the mode, the configuration is no longer mandatoryGOPATHIt’s too late

Under Windows platform, follow the steps below toE:\code\goAdd to environment variable

  1. My computer –> attribute –> Advanced system settings –> environment variable

  1. clickSystem variableLowernewly build, variable name writeGOPATH, variable value writeDirectory to save go code, I’m hereE:\code\go, click OK

  1. clickUser variableLowernewly build, variable name writeGOPATH, variable value writeDirectory to save go code, I’m hereE:\code\go, click OK

  1. stayGOPATHCreate three new folders under the directorybin: used to store executable files generated after compilationpkg: used to store archive files generated after compilationsrc: used to store source files

Configure Gobin

clickSystem variableLowernewly build, variable name writeGOBIN, variable value writeBin directory under the directory where the go code is saved, I’m hereE:\code\go\bin, click OK


Installing go under Linux

Let me take Ubuntu 2004 as an example.

Download go

wget https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz

If you want to install other versions, just change the version number.

After downloading, unzip to/usr/local/

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

Configure environment variables


sudo vim /etc/profile

After opening, add the following:

export GOROOT="/usr/local/go"
export GOPATH="/home/conan/go"
export GOBIN=$GOROOT/bin/
export GOARCH=386
export GOOS=linux
export GOTOOLS=$GOROOT/pkg/tool
export GOPROXY=https://goproxy.cn/,direct
export GO111MODULE=on

The effect after adding is as follows:



  • Goroot is the folder just downloaded and unzipped;
  • Add the path where the go command is located after the path, so that entering go anywhere can be recognized;
  • Gopath is set according to your personal situation. I recommend setting this to the go folder under the main folder (created by yourself). Later, some packages from GitHub should be placed in the SRC folder of $gopath, so that these packages can be found in the program.
  • 。。。

Finish modificationprofileAfter the file, execute the following command to make it effective:

source /etc/profile

Restart the system

Then, entergo env, see the following output to explain that the installation is successful and the configuration is effective.


Li peiguan blog