Go language development editor vscode configuration, and solve the problem of failure of vscode to download go dependencies and prompt tools

Visual Studio Code, referred to as VS Code, is currently the most widely used editor. Although it was released by Microsoft in 2015, it is relatively young compared to other popular editors, but it has been continuously updated in the past few years, and it was selected as the most popular among web developers in the latest Stack Overflow survey. Popular text editor.

1. Editor

1.1. Windows system installation vs code

Visual Studio Code, referred to as VS Code, is currently the most widely used editor. Although it was released by Microsoft in 2015, it is relatively young compared to other popular editors, but it has been continuously updated in the past few years, and it was selected as the most popular among web developers in the latest Stack Overflow survey. Popular text editor.

Every feature found in VS Code does an excellent job, building some simple feature sets, including syntax highlighting, smart completion, integrated git and editor built-in debugging tools, etc., will make your development more efficient .

1.2. Configuration

1.2.1. Install the Simplified Chinese plug-in

Click the last item on the left menu bar to manage extensions, enter Chinese in the search box, select the first item in the result list, and click install to install.

After the installation is complete, you will be prompted to restart VS Code in the lower right corner. After restarting, your VS Code will display Chinese!

vscode

1.2.2. Install the go plugin

Start vscode to select the plug-in -> search go to select the Go for Visual Studio Code plug-in and click to install. As shown in the picture:

vscode

1.3. Install the Go language development kit

Provide us with functions such as code hints and code auto-completion during Go language development.

Press Ctrl+Shift+P on the Windows platform, and Command+Shift+P on the Mac platform. At this time, an input box will pop up on the VS Code interface, as shown in the figure below:

vscode

We enter >go:install in this input box, and the relevant commands will be automatically searched below. We choose the command Go:Install/Update Tools

vscode

Select and press Enter to execute the command
vscode

VS Code will download and install the 7 tools listed in the above figure at this time, but the installation will basically fail due to the network environment.

1.3.1. Here is a recommended solution, practice it yourself:

We can manually download the tool from github:

第一步:现在自己的GOPATH的src目录下创建golang.org/x目录

第二步:在终端/cmd中cd到GOPATH/src/golang.org/x目录下

第三步:执行git clone https://github.com/golang/tools.git tools命令

第四步:执行git clone https://github.com/golang/lint.git命令

第五步:按下Ctrl/Command+Shift+P再次执行Go:Install/Update Tools命令,在弹出的窗口全选并点击确定,这一次的安装都会SUCCESSED了。

However, some environments may still fail to pull after setting the above operations. This is the need to check the underlying environment of go.

go env

Use the above command to view the Go language environment installed on the current computer, mainly to view the two parameters GO111MODULE and GOPROXY. These two parameter values ​​can be set to the following values:

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

After the above steps, the installation is successful. At this time, if you create a Go file, you can use code hints, code formatting and other tools normally.

We welcome your valuable comments, and hope this article can help everyone in need.

Guess you like

Origin blog.csdn.net/weixin_43672348/article/details/127397818
Recommended