我的vscode-go的settings.json文件
支持go module
平时开发使用vscode的时候,已经完全使用go module了。
如果你发现你的机器在go语言标准包提示消耗的时间很长,请
将GO111MODULE设为auto/off。
使用这个配置记得将环境变量−>添加/设置为:\color{red}{使用这个配置记得将环境变量->添加/设置为:}使用这个配置记得将环境变量−>添加/设置为:
GO111MODULE=on\color{#ff00ff}{GO111MODULE=on}GO111MODULE=on
然后网上看到说vscode不支持\color{#ff0000}{然后网上看到说vscode不支持}然后网上看到说vscode不支持
第三方包/自定义包的包函数/变量等内容的自动提示/完成。\color{#ff0000}{第三方包/自定义包的包函数/变量等内容的自动提示/完成。}第三方包/自定义包的包函数/变量等内容的自动提示/完成。
..我能说我的不会遇到这个问题吗?anyway,现在配置好后,\color{#ff00ff}{.. 我能说我的不会遇到这个问题吗?anyway,现在配置好后,}..我能说我的不会遇到这个问题吗?anyway,现在配置好后,
使用go.mod了,没有遇到这个问题了。记得项目目录下,gomodinit一下。\color{#ff00ff}{使用go.mod了,没有遇到这个问题了。记得项目目录下,go mod init 一下。}使用go.mod了,没有遇到这个问题了。记得项目目录下,gomodinit一下。
{
"go.goroot": "D:\\go",
"go.gopath": "D:\\go_project",
"go.inferGopath": false,
"go.toolsGopath": "D:\\go_project",
"window.zoomLevel": 0,
"git.autofetch": true,
"terminal.integrated.shell.windows": "powershell.exe", // 也可以使用 cmd.exe
// "terminal.integrated.shellArgs.windows": [
// "/k",
// "D:\\Applications\\Cmder\\Cmder.exe"
// ],
"workbench.colorTheme": "Monokai Pro (Filter Machine)",
"workbench.iconTheme": "Monokai Pro (Filter Machine) Icons",
"editor.renderControlCharacters": false,
"editor.snippetSuggestions": "top",
"editor.suggest.snippetsPreventQuickSuggestions": true,
"breadcrumbs.enabled": true,
"terminal.explorerKind": "external",
"editor.cursorStyle": "block",
"editor.links": false,
"editor.mouseWheelZoom": true,
"editor.renderLineHighlight": "all",
"editor.suggest.shareSuggestSelections": true,
"outline.icons": true,
"search.showLineNumbers": true,
"search.smartCase": true,
// package 查找模式
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeGoroot": true,
"go.gotoSymbol.includeImports": true,
// build 相关
"go.buildOnSave": "off",
"go.gocodeAutoBuild": true,
"go.installDependenciesWhenBuilding": true,
"go.buildFlags": [],
"go.buildTags": "",
"go.coverOnSingleTest": true,
"go.useCodeSnippetsOnFunctionSuggest": true,
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
"go.docsTool": "guru",
"go.formatTool": "goimports",
"go.lintTool": "golangci-lint",
"go.lintOnSave": "package",
"go.lintFlags": [
"--fast"
],
"go.formatFlags": [],
"go.vetFlags": [],
"go.vetOnSave": "package",
"go.generateTestsFlags": [],
"go.liveErrors": {
"enabled": true,
"delay": 500
},
"go.gocodeFlags": [
"-builtin",
"-ignore-case",
"-unimported-packages"
],
"go.enableCodeLens": {
"references": true,
"runtest": true
},
"go.delveConfig": {
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 64,
"maxArrayValues": 64,
"maxStructFields": -1
},
"apiVersion": 2,
"showGlobalVariables": true
},
"go.editorContextMenuCommands": {
"toggleTestFile": true,
"addTags": true,
"removeTags": true,
"testAtCursor": true,
"testFile": true,
"testPackage": true,
"generateTestForFunction": true,
"generateTestForFile": true,
"generateTestForPackage": true,
"addImport": true,
"testCoverage": true,
"playground": true,
"debugTestAtCursor": true
},
"go.playground": {
"openbrowser": false,
"share": false,
"run": false
},
"go.addTags": {
"tags": "json",
"options": "json=omitempty",
"promptForTags": true,
"transform": "snakecase"
},
"go.removeTags": {
"tags": "",
"options": "",
"promptForTags": false
},
"[go]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
"go.alternateTools": {
"go-langserver": "gopls",
},
"go.useLanguageServer": false,
"go.languageServerFlags": [],
"go.languageServerExperimentalFeatures": {
"format": true,
"autoComplete": true,
"rename": true,
"goToDefinition": true,
"hover": true,
"signatureHelp": true,
"goToTypeDefinition": true,
"goToImplementation": true,
"documentSymbols": true,
"workspaceSymbols": true,
"findReferences": true,
"diagnostics": false
}
}
本文介绍了VSCode中Go语言的配置,支持go module。若机器在Go标准包提示耗时久,可将GO111MODULE设为auto/off,同时将环境变量设为GO111MODULE=on。还提到网上说VSCode不支持第三方包自动提示,配置好并使用go.mod后此问题可解决,项目目录下需gomod init。
3万+

被折叠的 条评论
为什么被折叠?



