golang | windows platform golang environment building (after passing the pit)

background

My environment

  • Windows 10 (detailed version doesn't matter)
  • go latest version
  • vscode editor (not IDE, IDE needs money for goland)
  • Guangzhou China Mobile Network

golang installation

  1. download
    • The official website https://golang.org can't be opened in China. All the reasons are clear.
    • Domestic https://studygolang.comGo Chinese language network. Version will not be up to date.
    • Domestic https://go-zh.org/doc/installGo Chinese image station (this website can't be downloaded, and I don't understand it).
  2. install
    • Generally, you can choose MSI format to install. You can choose zip. But environment variables are added by themselves.
    • The installation is also very simple, step by step next.
    • zip format, unzip my computer properties and change the environment variables.

Configuration of environment variables

  1. win10 is a bit disgusting. It's hard to find some configured interfaces, so start - > search, or right-click to start searching again.
  2. Use this figure to configure some path variables of global users and current users (if GoPath needs to be changed, it is better to move bin, src and pkg under the path to the changed place together, because some tools, such as format code, will be stored in bin directory. If they are not migrated together, the format will be useless and need to be downloaded again.)
  3. Configure the environment variables again (D:\go\bin is the path where I install go)

Development environment

  1. install
    I'll skip it here. It's the same operation as installing go.
  2. Install Go plug in
    1. Configure the GoProxy address: https://goproxy.cn or https://goproxy.io. I usually use CN.
    2. All the downloaded tools will be placed in the bin directory of the GoPath directory. Sometimes the compatibility of vscode depends on the exe here.
    3. Generally, it can be updated. If not, go to the src of GoPath and execute git clone https://github.com/a/x.git
    4. At this time, all files are in src, and then go install github.com/a/x. (third party packages can also be installed in this way)

VSCode configuration

  1. debug configuration
{
    // Use IntelliSense for properties. 
    // Hover to view the description of an existing property.
    // For more information, please visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "LaunchGO",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "remotePath": "",
            "port": 5546,
            "host": "127.0.0.1",
            "program": "${fileDirname}",
            "env": {
                "GOPATH":"C:/Users/kernel/go",
                "GOROOT":"D:/go"
            },
            "args": []
        }
    ]
}
  1. Set up vscode configuration
    1. Using ctrl +, open the configuration.
    2. My configuration is as follows
{
"editor.wordwrap":"on",
"editor.minimap.renderCharacters": false,
"editor.minimap.enabled": false,
"terminal.external.osxExec": "iTerm.app",
"go.docsTool": "gogetdoc",
"go.testFlags": ["-v","-count=1"],
"go.buildTags": "",
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatTool": "goreturns",
//"go.formatTool": "goimports",
"go.goroot":"D:\\Go\\",
"go.gopath":"C:\\Users\\kernel\\go",
"go.autocompleteUnimportedPackages": true,
"go.formatOnSave":true,
"window.zoomLevel": 0,
"debug.console.fontSize": 16,
"debug.console.lineHeight": 30,
"git.path": "D:\\Program Files\\Git\\bin\\git.exe",
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"workbench.statusBar.visible": true,
"files.autoSaveDelay": 30000,
"explorer.confirmDelete": false,
//"editor.suggest.snippetsPreventQuickSuggestions": false,
//"go.useLanguageServer": true
//"http.proxy": "http://127.0.0.1:1080",
//"go.inferGopath": true
// "[javascript]":{
//     "editor.defaultFormatter": "HookyQR.beautify"
// },
// "[html]":{
//     "editor.defaultFormatter": "HookyQR.beautify"
//     //"editor.suggest.insertMode": "replace"
// },
}
Published 18 original articles, won praise and 861 visitors
Private letter follow

Keywords: git Windows network github

Added by Crysma on Fri, 14 Feb 2020 13:40:11 +0200