Home  >  Article  >  Backend Development  >  Teach you step by step how to configure Golang environment

Teach you step by step how to configure Golang environment

Go语言进阶学习
Go语言进阶学习forward
2023-07-20 16:27:15795browse
This time we will arrange how to configure the Go language development environment on the win platform.

# Overall, Go configuration environment is quite easy, similar to Python, and environment variables will be added automatically.


Download address

Go official mirror site:

https://golang.google.cn/dl/

Just choose the highest default version, the Go code is backward compatible, Differences between versions don't matter

Teach you step by step how to configure Golang environment


#Install

1. Find the downloaded installation file.

Teach you step by step how to configure Golang environment

2. Double-click to install

Teach you step by step how to configure Golang environment

3. Select Agree

Teach you step by step how to configure Golang environment

##4.Customize Install location.

Teach you step by step how to configure Golang environment

##5. Click install to install.

Teach you step by step how to configure Golang environment

6. Installation is in progress, wait until the installation is completed.

Teach you step by step how to configure Golang environment

7. Click finish to complete the installation.

Teach you step by step how to configure Golang environment

Check whether the installation is successful

After the above installation process is OK, open the CMD window , enter the go version command, as shown

Teach you step by step how to configure Golang environment

Note:Since it is already version 1.11, we will use go mod to manage dependencies in the future, no configuration is requiredGOPATH and other weird stuff.


Configure GOPROXY (agent)

Maybe we need Use Go to download some packages or something.

But the default official website source, GOPROXY=https://proxy.golang.org,direct, is in Unable to access in China

输入go env查看Go配置

Teach you step by step how to configure Golang environment

需要修改成国内镜像站点,这里推荐:

https://goproxy.io

执行以下命令,进行修改

go env -w GOPROXY=https://goproxy.cn,direct

重新打开CMD,执行go env查看Go配置

Teach you step by step how to configure Golang environment

Go development editor

Go’s current development editors mainly include VSCode, GolandTwo kinds. The recommended ones for this tutorial are Goland, and PycharmBelong to the same company. The installation and cracking of Goland will not be described here.


Why didn’t you choose VSCode

When I first started writing Go, I actually used VSCode , but I found when using it, VSCode always does not prompt automatically, and the automatic save setting often fails automatically. I have experienced this several times. After much trouble, I finally embraced the IDE developed specifically for Go, Goland!!!, it’s so delicious.

The above is the detailed content of Teach you step by step how to configure Golang environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:Go语言进阶学习. If there is any infringement, please contact admin@php.cn delete