go language (1) environment construction and editor choice

Detailed reference address

For detailed steps, please refer to teacher Li Wenzhou’s blog

download link

Go official mirror station (recommended): https://golang.google.cn/dl/

Installation (only windows here)

After downloading, just install it in the next step

an examination

Under cmd, execute'go version', and if the version appears, the installation is successful
Insert picture description here

Environment variable

Set GOPATH to a commonly used project directory.
For example, my commonly used directory is: d:\goCode, directly in the environment variable, point GOPATH to d:\goCode
and some detailed settings, please move to the beginning of the article for details Teacher Li Wenzhou's blog
Insert picture description here

editor

VS code

The full name of VS Code is Visual Studio Code. It is a free, modern and lightweight code editor open sourced by Microsoft. It supports syntax highlighting, smart code completion, custom hotkeys, bracket matching, and code snippets in almost all mainstream development languages. , Code comparison Diff, GIT and other features, support plug-in extension, support Win, Mac and Linux platforms.

Although not as powerful as some IDEs, it is sufficient for our daily Go development after adding Go extension plug-ins.

installation

VS Code official download address: https://code.visualstudio.com/Download,
just go in and choose the platform that suits you to download it.
Tucao, it’s actually very difficult to download. It took a lot of time to download without success.
Recommendation: Directly use the computer butler The software manages search and downloads, which is very convenient and fast. Confiscated money is not an advertisement
Insert picture description here

Configuration

Sinicization

Click the last management extension in the left menu bar, 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!Insert picture description here

Install go extension

Now we have to install the Go extension plug-in for our VS Code editor to support Go language development.
Insert picture description here

Install go-related development plugins

Code completion and other plug-ins usually fail to install using VS code . Just use the go_tools extracted code compiled by Mr. Li Wenzhou : 1tsv, and download the one suitable for your system to the bin folder under the GOPATH set at the beginning.
Insert picture description here

Go project file

Three folders can be created in the project folder, bin, pkg and src.
Insert picture description here
The project directory can be saved in this structure, the src decentralizes the specific domain name (for example, github.com), the domain name decentralizes the developer folder, and the developer decentralizes the specific project. See specific development requirements
src->domain name->developer->project
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_15915293/article/details/114442710