Installation and use of vs Code in go language integrated development environment

Time:2022-5-4
catalogue
  • Go languageIntegrated development environmentofVS CodeInstallation and use

    • Download and install
    • Install Chinese Simplified plug-in
    • Install go development extension
    • Change editor theme
    • Install go language development kit
    • Configure vscode to enable automatic saving
    • Configure code snippet shortcuts

 

Installation and use of vs Code in go language integrated development environment

Vs code is an open source editor of Microsoft, and the plug-in system is very rich. The following describes how to build a go language development environment with vs code

 

Download and install

Vs code official download address

The three mainstream platforms support it. Please select the corresponding installation package according to your computer platform.

Installation and use of vs Code in go language integrated development environment

Double click the downloaded installation file and double click the installation.

 

Install Chinese Simplified plug-in

Click the last item in the menu bar on the leftManagement extension, inSearch boxMedium inputchinese, select the first item in the result list and clickinstallInstallation.

After installation, a prompt will appear in the lower right cornerRestart vs Code, after restart, your vs code will be displayed in ChineseVSCodeIntroduction to main interface:

Installation and use of vs Code in go language integrated development environment

 

Install go development extension

Now we are going to install for our vs code editorGoExtension to support go language development.

Installation and use of vs Code in go language integrated development environment

 

Change editor theme

Click in turnSettings - > color themeThe following window will pop up:

Installation and use of vs Code in go language integrated development environment

You can choose the corresponding theme according to your preferences.

 

Install go language development kit

During the development of go language, you will provide us with functions such as code prompt, automatic code completion and so on.

Please set it before doing soGOPROXY, open the terminal and execute the following commands:

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

Windows platform pressCtrl+Shift+P, for Mac platformsCommand+Shift+PAt this time, an input box will pop up on the vs code interface, as shown in the following figure:

Installation and use of vs Code in go language integrated development environment

We type in this input box>go:install, the following will automatically search for relevant commands. We chooseGo:Install/Update ToolsSelect this command as shown in the figure below and press enter to execute the command (or click the command with the mouse)Select all in the pop-up window and click “OK” to install.

Installation and use of vs Code in go language integrated development environment

Then the following window will pop up to start installing the tool:

Installation and use of vs Code in go language integrated development environment

Drink water and wait until all tools are installed successfully, as shown in the figure below:

Installation and use of vs Code in go language integrated development environment

 

Configure vscode to enable automatic saving

Click as shown in the figure belowFile - > Preferences - > SettingsOpen the setting page to see the relevant configuration of automatic saving, as shown in the figure below. You can choose the method of automatic saving according to your preferences:

Installation and use of vs Code in go language integrated development environment

 

Configure code snippet shortcuts

Or pressCtrl/Command+Shift+P, enter according to the following figure>snippets, select the command and execute:

Installation and use of vs Code in go language integrated development environment

Then click Select in the pop-up windowgoOptions:Then the following page pops up:

Installation and use of vs Code in go language integrated development environment

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

"Put a name here":{

among$0Indicates the position of the final cursor. For example, I created two shortcuts here. One is inputplnWill be inserted in the editorfmt.Println()code; inputplf, it will be insertedfmt.Printf("")code.

{
	"println":{
		"prefix": "pln",
		"body":"fmt.Println($0)",
		"description": "println"
	},
	"printf":{
		"prefix": "plf",
		"body": "fmt.Printf("$0")",
		"description": "printf"
	}
}

Paste the above code into the configuration file as shown in the figure below, save and close the configuration file.After adding the above configuration, save it. Let’s open a go file and test the effect:

Installation and use of vs Code in go language integrated development environment

At this stage, it will be dominated by programmers, even more than ever before.

This is the end of this article about the installation and use of vs Code in go language integrated development environment. For more information about the installation and use of go language vs code, please search the previous articles of developeppaper or continue to browse the relevant articles below. I hope you will support developeppaper in the future!