简体   繁体   English

如何在 Windows 的 sublime text 3 中设置 Gosublime?

[英]How to setup Gosublime in sublime text 3 in Windows?

The main problem here is .. that I have installed the package control and also the gosublime plugin but it is not working.这里的主要问题是.. 我已经安装了包控件和 gosublime 插件,但它不起作用。 Also it is not working in the command prompt when I type go.当我输入 go 时,它也无法在命令提示符下工作。 It gives info proving that the go is installed correctly in path I am actually trying to use a separator to set paths for go and java simultaneously which I might be doing wrong.它提供的信息证明 go 已正确安装在路径中我实际上是在尝试使用分隔符同时设置 go 和 java 的路径,我可能做错了。

ENVIRONMENT VARIABLE环境变量

Now in sublime text 3 i am receiving an error as现在在崇高的文本 3 我收到一个错误

MarGo: Missing required environment variables: GOPATH | MarGo:缺少必需的环境变量:GOPATH | > See the Quirks section of USAGE.md for info > 有关信息,请参阅 USAGE.md 的Quirks部分

I went through this but it didnt help me我经历了这个,但它没有帮助我

Sublime Text: "MarGo: Missing required environment variables: GOPATH" Sublime Text:“MarGo:缺少必需的环境变量:GOPATH”

in windows sublime text 3在 windows sublime text 3
ctrl+shift+p ctrl+shift+p
type install package enter输入安装包回车
search for golang build enter搜索golang build回车

You have to set the GOPATH environment variable to something like d:\\myprojects\\go .您必须将GOPATH环境变量设置为d:\\myprojects\\go That's where your code and libraries will be stored.这就是您的代码和库的存储位置。

Your code should be located in a folder like d:\\myprojects\\go\\src\\github.com\\pandey\\coolproject .您的代码应该位于像d:\\myprojects\\go\\src\\github.com\\pandey\\coolproject这样的文件夹中。

Relevant section from the docs:文档中的相关部分:

[...] [...]

Test your installation测试您的安装

Check that Go is installed correctly by setting up a workspace and building a simple program, as follows.通过设置工作区和构建一个简单的程序来检查 Go 是否正确安装,如下所示。

Create a directory to contain your workspace, $HOME/work for example, and set the GOPATH environment variable to point to that location.创建一个目录来包含您的工作区,例如 $HOME/work,并将 GOPATH 环境变量设置为指向该位置。

$ export GOPATH=$HOME/work You should put the above command in your shell startup script ($HOME/.profile for example) or, if you use Windows, follow the instructions above to set the GOPATH environment variable on your system. $ export GOPATH=$HOME/work 你应该把上面的命令放在你的 shell 启动脚本中(例如 $HOME/.profile),或者,如果你使用 Windows,按照上面的说明在你的系统上设置 GOPATH 环境变量。

Next, make the directories src/github.com/user/hello inside your workspace (if you use GitHub, substitute your user name for user), and inside the hello directory create a file named hello.go with the following contents:接下来,在您的工作区中创建目录 src/github.com/user/hello(如果您使用 GitHub,请将您的用户名替换为 user),并在 hello 目录中创建一个名为 hello.go 的文件,其中包含以下内容:

[...] [...]

( https://golang.org/doc/install#testing ) ( https://golang.org/doc/install#testing )

See the Go docs for more details, especially on how to do it on windows: https://golang.org/doc/install有关更多详细信息,请参阅 Go 文档,尤其是如何在 Windows 上执行此操作: https : //golang.org/doc/install

I haven't had a good experience installing gosublime recently, the margo instructions are not very helpful.我最近安装 gosublime 的经验不是很好,margo 说明不是很有帮助。 You could try gopls instead, it's still in alpha, but it's developed by the go team.你可以试试 gopls,它仍处于 alpha 阶段,但它是由 go 团队开发的。 It's a language server for go, that works with a Sublime LSP plugin.它是一个用于 go 的语言服务器,可与 Sublime LSP 插件配合使用。

https://github.com/golang/tools/tree/master/gopls https://github.com/golang/tools/tree/master/gopls

Instructions for Sublime are here . Sublime 的说明 在这里

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

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