Article directory
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
Configuration complete infographic
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