问题
Vscode
对 go
代码要求过于严苛,可能会出现闪烁等问题。
解决
打开 settings.json
文件,配置如下
![](https://i-blog.csdnimg.cn/blog_migrate/8341766292fc549d11d0973d829d2eee.png)
{
"go.inferGopath": false,
"go.lintFlags": [
"-min_confidence=.8"
],
}
一份具体的配置:
{
"go.useLanguageServer": true,
"timeline.excludeSources": [],
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
"completeUnimported": true,
"usePlaceholders": true,
"completionDocumentation": true,
"deepCompletion": true,
"matcher": "fuzzy",
"hoverKind": "SynopsisDocumentation" // No/Synopsis/Full, default Synopsis
},
"files.eol": "\n", // formatting only supports LF line endings
"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
},
"emmet.excludeLanguages": [
"markdown"
],
"go.addTags": {
},
"go.inferGopath": false,
"go.lintFlags": [
"-min_confidence=.8"
],
}