go - 通过Visual Studio Code读取golang源代码,编译器警告,如何修复

标签 go visual-studio-code

下载源码

git clone https://github.com/golang/go.git  golang


通过Visual Studio Code打开golang,警告信息 enter image description here

enter image description here

我尝试打开bufio enter image description here

如何解决这个问题

最佳答案

按照错误中给定的链接进行操作: Setting up your workspace

As of Jan 2021, if you are working with multiple modules or nested modules, you will need to create a "workspace folder" for each module. This means that each module has its own scope, and features will not work across modules. We are currently working on addressing this limitation--see details about experimental workspace module mode below.

In VS Code, you can create a workspace folder by setting up a multi-root workspace. View the documentation for your editor plugin to learn how to configure a workspace folder in your editor.

然后点击此链接: multi-root workspace

您将看到如何将文件夹添加到工作区。 所以基本上在 VS Code 中这样做,解决了问题:

文件 > 将文件夹添加到工作区 >“选择所需的文件夹”

但是,在我看来,您想要做的是从源代码安装 Go。如果这就是您的目标,您应该严格遵循文档并在您的 GOROOT 上执行此安装: Install-Go-From-Source

在文档中的 all.bash 脚本中,您将看到如下行:

echo 'all.bash must be run from $GOROOT/src' 1>&2

或者如果您想贡献 Go 源代码,请遵循此文档: Contribution Guidelines

关于go - 通过Visual Studio Code读取golang源代码,编译器警告,如何修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70143575/

相关文章:

go - ioutil.ReadAll 为 tar 阅读器提供 0 个字节

go - 如何从客户端发送 grpc 元数据

visual-studio-code - 如何下载旧版本的 VSCode 便携版?

go - 在推断出 GOPATH 时运行(安装)go 代码

如果我包装我的对象,Golang 转换为自定义类型会失败

string - 格式化包含 '%' golang 的字符串

ssh - VSCode 远程 SSH 连接失败

html - 如何使用 Emmet 在 VSCode for HTML 中添加注释标签?

node.js - 如何从浏览器中的精简服务器中删除 "Connected to BrowserSync"徽章

intellisense - 如何在 VS Code 中为 Backbone 启用 IntelliSense