Vscode 解决Golang无法跳转到定义

首先,需要安装好 go 插件,插件市场搜索go,选一个即可安装。

然后,需要安装 go 的工具包。在 vscode 中,输入快捷键:command(ctrl) + shift + p,在弹出的窗口中,输入:go:install/Update Tools,回车后,选择所有插件(勾一下全选),点击确认,进行安装(设置GOPROXY)。

接下来,在项目的 settings.json 文件中添加配置:

   "go.goroot": "D:\\Go",
    "go.gopath": "D:\\gopath",
    //第三方库代码提示
    "go.inferGopath": true,
    "go.formatTool": "goreturns",
    //自动完成未导入的包
    "go.autocompleteUnimportedPackages": true,
    "go.gocodePackageLookupMode": "go",
    "go.gotoSymbol.includeImports": true,
    "go.docsTool": "gogetdoc",
    "go.useCodeSnippetsOnFunctionSuggest": true,
    "go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
    "go.useLanguageServer": true,
    "[go]": { 
        "editor.formatOnSave": true, 
        "editor.codeActionsOnSave": { 
            "source.organizeImports": true, 
        },    // Optional: Disable snippets, as they conflict with completion ranking.    "editor.snippetSuggestions": "none", 
    },"[go.mod]": { 
        "editor.formatOnSave": true, 
        "editor.codeActionsOnSave": { 
            "source.organizeImports": true, 
        },
    },"go.trace.server": "verbose", 
    "gopls": { 
        // Add parameter placeholders when completing a function. 
       "usePlaceholders": false, 
       // If true, enable additional analyses with staticcheck. 
       // Warning: This will significantly increase memory usage.   "staticcheck": false, 
    },"go.languageServerFlags": [ 
        "-remote=auto", "-logfile=auto", "-debug=:0", "-rpc.trace", 
    ], 

首选项-设置 去掉 Use Language Server

Vscode 解决Golang无法跳转到定义_第1张图片

本文由博客一文多发平台 OpenWrite 发布!

你可能感兴趣的:(安全)