How to setup VSCode for golang/go cmd module?

huangapple go评论76阅读模式
英文:

How to setup VSCode for golang/go cmd module?

问题

它在 VSC 上对于 std 模块(golang/go 根目录)工作得很好。然而,在 cmd 模块(从 src/cmd 目录打开)上不起作用。没有代码导航、符号搜索,甚至没有任何问题/错误报告。

版本信息:

vscode: 1.61.0
vscode-go: v0.28.1

已安装的 Go 工具:

gopkgs
go-outline
gotests
gomodifytags
impl
goplay
dlv
dlv-dap
staticcheck
gopls

英文:

It works well for std module (golang/go root directory) on VSC. However it doesn't work on cmd module (opened from src/cmd directory). There were no code navigation, symbol search, and even any problems/errors reported.

Version info:

vscode: 1.61.0
vscode-go: v0.28.1

Installed go tools:

gopkgs
go-outline
gotests
gomodifytags
impl
goplay
dlv
dlv-dap
staticcheck
gopls

答案1

得分: 0

$WORKSPACE/go打开VSC。按照https://github.com/golang/tools/blob/master/gopls/doc/advanced.md#working-on-the-go-source-distribution中@hana提到的说明进行操作:

  1. 编译Go二进制文件。将工作目录更改为$WORKSPACE/go/src,然后运行./make.bash(或Windows cmd中的./make.bat)。它将生成$WORKSPACE/go/bin目录。

  2. "go.goroot"设置为"${workspaceFolder}"并安装所有所需的Go工具。

英文:

Open VSC from $WORKSPACE/go. Follow the instruction of https://github.com/golang/tools/blob/master/gopls/doc/advanced.md#working-on-the-go-source-distribution as @hana mentioned:

  1. Compile the Go binary. Change working directory to $WORKSPACE/go/src and run ./make.bash (or ./make.bat for Windows cmd). It will generate the $WORKSPACE/go/bin directory.

  2. Set "go.goroot" to "${workspaceFolder}" and install all Go tools required.

huangapple
  • 本文由 发表于 2021年10月13日 16:35:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/69552237.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定