VSCode Golang代码提示

首先,需要安装好 go 插件,之间在插件市场输入go,选一个即可安装。

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

Installing 18 tools at /Users/liaojinlong/Workspace/CPChain/chain/bin  
  gocode
  gopkgs
  go-outline
  go-symbols
  guru
  gorename
  dlv
  gocode-gomod
  godef
  goimports
  golint
  gopls
  gotests
  gomodifytags
  impl
  fillstruct
  goplay
  godoctor

Installing github.com/mdempsky/gocode SUCCEEDED  
Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED  
Installing github.com/ramya-rao-a/go-outline SUCCEEDED  
Installing github.com/acroca/go-symbols SUCCEEDED  
Installing golang.org/x/tools/cmd/guru SUCCEEDED  
Installing golang.org/x/tools/cmd/gorename SUCCEEDED  
Installing github.com/go-delve/delve/cmd/dlv SUCCEEDED  
Installing github.com/stamblerre/gocode SUCCEEDED  
Installing github.com/rogpeppe/godef SUCCEEDED  
Installing golang.org/x/tools/cmd/goimports SUCCEEDED  
Installing golang.org/x/lint/golint SUCCEEDED  
Installing golang.org/x/tools/cmd/gopls SUCCEEDED  
Installing github.com/cweill/gotests/... SUCCEEDED  
Installing github.com/fatih/gomodifytags SUCCEEDED  
Installing github.com/josharian/impl SUCCEEDED  
Installing github.com/davidrjenni/reftools/cmd/fillstruct SUCCEEDED  
Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED  
Installing github.com/godoctor/godoctor SUCCEEDED  

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

"go.autocompleteUnimportedPackages": true,
"go.docsTool": "gogetdoc",
"go.formatTool": "goimports",

重启 VSCode。


转载请注明出处http://zgljl2012.com/vscode-golangdai-ma-ti-shi/

LiaoJinLong

天道酬勤

订阅 技术博客

将最新文章推送至您的邮箱.

2693491512@qq.com