Centos7.6 version of Linux download and install Go language environment configuration, install Go1.18 version tutorial notes-2023 version

1. Install Go environment under Linux

It is recommended to install Go under linux, because some windows configurations do not work, and I encountered it when I was doing Mit6.824, so record how to install go under linux environment

1. Remote access

 wget -c https://studygolang.com/dl/golang/go1.15.linux-amd64.tar.gz
  • This can be run directly in a virtual machine, or can be downloaded from the Go official website, and then uploaded for decompression

2. Unzip

tar -zxvf go1.15.linux-amd64.tar.gz -C /usr/local 

3. Add environment variables

It is necessary to add the GO environment variable to the system $PATH.
The GOPATH environment variable specifies a directory, which is the working directory, which contains all our go source code.
The code we wrote can be placed under this directory

  • Just execute the following code
# 创建一个目录
mkdir -p /home/user/goproject
#打开配置环境变量的文件
vim /etc/profile
#设置
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/goproject
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
# 使得配置文件生效
source /etc/profile
# 查看是否生效
go version
go env

5. Go environment configuration diagram

insert image description here

Configuration complete infographic

insert image description here

2. VsCode connects us to Go

It is impossible for us to develop in a virtual machine, so we choose an IDE for development

For detailed documentation, refer to the official website: https://code.visualstudio.com/docs/remote/ssh#_connect-to-a-remote-host

2.1 Install the corresponding plug-in

insert image description here

2.2 Connecting

insert image description here

3. Related configuration

insert image description here

4. Successful connection

insert image description here

Guess you like

Origin blog.csdn.net/weixin_59823583/article/details/131382866