简体   繁体   English

如何为 golang/go cmd 模块设置 VSCode?

[英]How to setup VSCode for golang/go cmd module?

It works well for std module ( golang/go root directory) on VSC.它适用于 VSC 上的std模块( golang/go根目录)。 However it doesn't work on cmd module (opened from src/cmd directory).但是它不适用于cmd模块(从src/cmd目录打开)。 There were no code navigation, symbol search, and even any problems/errors reported.没有代码导航、符号搜索,甚至没有报告任何问题/错误。

Version info:版本信息:

vscode: 1.61.0 vscode-go: v0.28.1 vscode: 1.61.0 vscode-go: v0.28.1

Installed go tools:安装的 go 工具:

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

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

  1. Compile the Go binary.编译 Go 二进制文件。 Change working directory to $WORKSPACE/go/src and run ./make.bash (or ./make.bat for Windows cmd).将工作目录更改为$WORKSPACE/go/src并运行./make.bash (或./make.bat for Windows cmd)。 It will generate the $WORKSPACE/go/bin directory.它将生成$WORKSPACE/go/bin目录。

  2. Set "go.goroot" to "${workspaceFolder}" and install all Go tools required."go.goroot"设置为"${workspaceFolder}"并安装所需的所有 Go 工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM