Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of go coding in vscode

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to solve the problem of go coding in vscode". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the problem of go coding in vscode".

Before correcting the problem, make sure you have downloaded go-tool, the official toolset of golang, correctly. If you are not sure, follow my steps again. Maybe after the operation, your problem will be solved.

1. Configure the source of golang.

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

Then we download the default tool service for the golang tool:

2. Windows platform Press Ctrl+Shift+P,Mac platform Press Command+Shift+P, at this time the VS Code interface will pop up an input box

3. We enter > go:install in this input box, and the following will automatically search for the relevant command. We select the command Go:Install/Update Tools, press the figure below to select it, and enter to execute the command.

Select all in the pop-up window and click the "OK" button to install.

Wait for the installation to be completed, because of the particularity of the domestic network, so who must know the proxy source of go, otherwise the download will always fail.

After performing this step, restart Vscode, and if you can solve your problem at this time, you don't need to look any further.

Solutions to specific problems

If the above steps do not solve your problem, you can set up your own problem.

F12 in VSCode cannot jump to the general setting.

Click on the gear in the lower left corner and select the settings interface (you can also click the CTRL+, shortcut key to click on the user-expand-go. Make the following settings

1. Change DocsTool to godoc

2. Remove the check box from Use Language Server

3. Restart VsCode

Go mod mode

If it still doesn't work after doing the above, and you are using go mod mode, there is a special way to solve this problem.

Execute the command go mod vendor to import dependencies, which transfers the dependencies to the vendor (automatic new) folder in the root directory of the project

At this point, F12 can jump the code.

Second, the code automatic take-out function is invalid.

This problem is usually caused by the switching of go mod mode. If your project uses Gopath mode (if there are students who don't know about Gopath and Gomod, you can see how my article views go moudle and apply it to work), then you need to set the

Go env-w GO111MODULE=off

At this time, the automatic take-out function may be used correctly.

If you are using go mod mode, set the

Go env-w GO111MODULE=on

The automatic take-out function can also return to normal.

Thank you for your reading, the above is the content of "how to solve the problem of go coding in vscode". After the study of this article, I believe you have a deeper understanding of how to solve the problem of go coding in vscode. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report