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

The method of configuring go language Development Environment by vscode

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces the method of vscode configuring go language development environment, which has certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

Install the Go development extension

Now we are going to install the Go extension for our VS Code editor to support Go language development.

Install the go language development kit

When the Windows platform presses the Ctrl+Shift+P,Mac platform and presses Command+Shift+P, the VS Code interface will pop up an input box, as shown below:

Enter > go:install in this input box, and the following will automatically search for related commands. We choose the command Go:Install/Update Tools.

Select and enter to execute the command (or click the command with the mouse)

Then click the "OK" button to install. The following input window pops up:

At this time, VS Code downloads and installs the 16 tools listed above, but installation failures occur due to the domestic network environment, such as the various FAILED shown below:

Solution: download the source code using git before installing

We can download the tool manually from github, (to perform this step, you must have git installed on your computer)

Step 1: now create a golang.org/x directory under the src directory of your own GOPATH

Step 2: cd to the GOPATH/src/golang.org/x directory in the terminal / cmd

Step 3: execute the git clone https://github.com/golang/tools.git tools command

Step 4: execute the git clone https://github.com/golang/lint.git command

Step 5: press Ctrl/Command+Shift+P to execute the Go:Install/Update Tools command again, select all in the pop-up window and click OK, this time the installation will be SUCCESSED.

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

Configure automatic Save

Click preferences-> Settings, and open the settings page to see that the relevant configurations are automatically saved as shown in the figure. You can choose the automatic saving method according to your preferences:

Configure code snippet shortcuts

Press Ctrl/Command+Shift+P again, enter > snippets according to the following figure, select the command and execute:

Then click to select the go option in the pop-up window:

You can take a brief look at the notes above and introduce the main usage:

Where $0 indicates the location of the final cursor. For example, I have created two shortcuts here, one is that typing pln inserts the fmt.Println () code in the editor, and typing plf inserts the fmt.Printf ("") code.

After adding the configuration above, save it.

Thank you for reading this article carefully. I hope it will be helpful for everyone to share the methods and contents of vscode to configure the go language development environment. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

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

Internet Technology

Wechat

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

12
Report