英文:
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提到的说明进行操作:
-
编译Go二进制文件。将工作目录更改为
$WORKSPACE/go/src
,然后运行./make.bash
(或Windows cmd中的./make.bat
)。它将生成$WORKSPACE/go/bin
目录。 -
将
"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:
-
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. -
Set
"go.goroot"
to"${workspaceFolder}"
and install all Go tools required.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论