英文:
GoType issues with SublimeLinter
问题
我对Go还有点陌生,最近一直在尝试使用SublimeLinter-contrib-gotype插件来对我的文件进行代码检查。大部分情况下它都工作得很好,但是如果我尝试从GitHub导入一个Go包,它就会出错。我一直在尝试使用Echo框架的简单示例。当我运行代码时,它可以正常工作,但是代码检查工具却出现了问题。
它报错说:
> 无法导入github.com/labstack/echo(找不到导入项: )
我已经运行了go get github.com/labstack/echo
命令,但似乎没有起作用。
我也附上了一张截图:
这是我使用的代码的链接:这里。
英文:
I'm a bit new to Go, and I've been trying to use the SublimeLinter-contrib-gotype package to lint my files. It works well for the most part, but for some reason it throws an error if I try to import a Go package from GitHub. I've been trying to use the simple example from the Echo framework. When I run the code, it works fine but for some reason the linter is causing issues.
It throws an error saying:
> could not import github.com/labstack/echo (can't find import: )
I've already run the go get github.com/labstack/echo
command, but it doesn't seem to have helped.
I've attached a screenshot as well:
And here is a link to the code I was using.
答案1
得分: 1
我遇到了同样的问题。尝试运行以下命令:
launchctl setenv GOPATH $GOPATH
然后重新启动 ST,但在重新启动后这个方法可能不起作用。
如果你使用 Go Sublime,下面的方法可能更好用。
Sublime Text 菜单 > Preferences > Package Settings > GoSublime > Settings - Default / User
"shell": ["/usr/bin/bash"],
"env": {"GOPATH": "/Users/username/gopath/"},
英文:
I'd faced the same problem. Try running
launchctl setenv GOPATH $GOPATH
and restarting ST, this won't work after a reboot.
If you use Go Sublime, the following should work better.
Sublime Text menu > Preferences > Package Settings > GoSublime > Settings - Default / User
"shell": ["/usr/bin/bash"],
"env": {"GOPATH": "/Users/username/gopath/"},
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论