Home>Article>Development Tools> How vscode configures the go language development environment

How vscode configures the go language development environment

王林
王林 Original
2019-12-30 16:01:48 3953browse

How vscode configures the go language development environment

Install Go development extension

Now we need to install the Go extension plug-in for our VS Code editor, let It supports Go language development.

How vscode configures the go language development environment

Install Go language development tool kit

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

How vscode configures the go language development environment

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

How vscode configures the go language development environment

How vscode configures the go language development environment

and select it and press Enter to execute the command (or click the mouse with the Command)

How vscode configures the go language development environment

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

VS Code will download and install the 16 tools listed above at this time. However, due to the domestic network environment, the installation will basically fail, as shown in the following FAILED:

How vscode configures the go language development environment

Solution: Use git to download the source code and then install it

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

Step one: Now create the golang.org/x directory under the src directory of your GOPATH

Step two: In the terminal/cmd, cd to the GOPATH/src/golang.org/x directory

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 and execute the Go:Install/Update Tools command again, Select them all in the pop-up window and click OK. This time the installation will be SUCCESSED.

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

Configuring automatic saving

Click Preferences->Settings. When you open the settings page, you can see the relevant configuration of automatic saving as shown in the figure. You can choose the automatic saving method according to your own preferences:

How vscode configures the go language development environment

Configure code snippet shortcut keys

or Press Ctrl/Command Shift P, enter >snippets as shown below, select the command and execute it:

How vscode configures the go language development environment

How vscode configures the go language development environment

## Then click in the pop-up window Select the go option:

You can briefly read the above comments, which introduce the main usage:

How vscode configures the go language development environment

where $0 represents the final position of the cursor. For example, I have created two shortcuts here. One is to enter pln and the fmt.Println() code will be inserted into the editor; enter plf and the fmt.Printf("") code will be inserted.

How vscode configures the go language development environment

After adding the above configuration, save it.

Recommended related articles and tutorials:

vscode tutorial

The above is the detailed content of How vscode configures the go language development environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Can vscode write java? Next article:Can vscode write java?