英文:
Golang auto completion nsf package
问题
我已经安装了Sublime和Go。
尝试了https://github.com/nsf/gocode提供的自动补全功能。
对于标准包,它运行得很完美。
但是对于从GitHub获取的外部包,它不起作用。
对此有任何帮助将不胜感激。谢谢。
英文:
I have installed sublime and go.
Tried the autocompletion feature offered by https://github.com/nsf/gocode.
It works perfectly for standard packages.
But not working for external packages like the ones fetched from github.
Any help on this appreciated. Thanks.
答案1
得分: 4
只有在构建和安装这些外部包之后才能正常工作。
如果你只是使用go get
获取它们的源代码,自动补全功能将无法工作,即使这些源代码位于GOPATH/src/...
中。
这些包至少需要被编译(GOPATH/pkg
)。
如在“Go如何更新第三方包?”中所提到的,可以使用go get -u all
命令来帮助更新。
英文:
It will only work if you build and install those external packages.
if you just go get
their sources, the completion won't work, even said sources are in the GOPATH/src/...
.
Those packages need to be at least compiled (GOPATH/pkg
).
As mentioned in "How does Go update third-party packages?", a go get -u all
can help.
答案2
得分: 0
为了使Go自动完成功能正常工作(Atom编辑器、Sublime甚至带有自动完成功能的vim),请按照以下步骤操作:
-
将您的包放置在Go路径中(如果项目在GitHub上并且您使用了get工具,这可以自动完成):
go get -u github.com/username/packageName
-
您必须构建您的包:
go build $GOPATH/pathToYourProject...
-
您必须安装您的包:
go install $GOPATH/pathToYourProject...
英文:
For go autocomplete to work (Atom Editor, Sublime, even vim with autocomplete)
-
Your package must be placed in the go path. (this can be automatically done if the project is on github and you use the get tool)
go get -u github.com/username/packageName
-
you must build your package
go build $GOPATH/pathToYourProject...
-
you must install your package
go install $GOPATH/pathToYourProject...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论