在不安装Go的情况下,是否有其他方法在VS Code中实现Golang代码补全?

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

Is there an alternative to get the Golang code completion in VS Code without installing Go?

问题

我的目标是在Docker上专门使用Go。换句话说,我尽量不直接在我的计算机上安装Go。我在VS Code上编写代码,并使用"Go"扩展。

问题是,当我创建一个main.go文件时,会出现错误:

在GOROOT()或PATH(/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin)中找不到"go"二进制文件。请检查PATH,或安装Go并重新加载窗口。如果PATH不是您预期的内容,请参阅https://github.com/golang/vscode-go/issues/971

在VS Code中有没有其他方法来获得代码补全功能?

英文:

My goal is to use Go exclusively on Docker. In other words, I try my best not to install Go directly to my computer. And, I am writing the code on a VS Code and use the "Go" extension.

The problem is that when I create a main.go it throws an error:

Failed to find the "go" binary in either GOROOT() or PATH(/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin). Check PATH, or Install Go and reload the window. If PATH isn't what you expected, see https://github.com/golang/vscode-go/issues/971

Is there an alternative to get the code completion feature in VS Code?

答案1

得分: 1

这可以通过使用远程开发扩展包来实现。VSCode有关于使用容器作为开发环境的详细文档。这将允许您享受Go扩展的所有功能,而无需在您的计算机上直接安装Go。您也可以选择在容器中安装扩展。

请参阅在容器中进行开发

英文:

This should be achievable using the Remote Development Extension pack. VSCode has good documentation on using containers as your development enviroment. This will allow you to enjoy all of the Go extension's features without needing Go to be installed directly on your machine. You can opt to install the extensions in the container as well.

See Developing inside a Container

huangapple
  • 本文由 发表于 2022年5月11日 20:43:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/72201279.html
匿名

发表评论

匿名网友

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

确定