Golang自动完成nsf包。

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

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),请按照以下步骤操作:

  1. 将您的包放置在Go路径中(如果项目在GitHub上并且您使用了get工具,这可以自动完成):

      go get -u github.com/username/packageName
    
  2. 您必须构建您的包:

      go build $GOPATH/pathToYourProject...
    
  3. 您必须安装您的包:

      go install $GOPATH/pathToYourProject...
    
英文:

For go autocomplete to work (Atom Editor, Sublime, even vim with autocomplete)

  1. 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
    
  2. you must build your package

     go build $GOPATH/pathToYourProject...
    
  3. you must install your package

     go install $GOPATH/pathToYourProject...
    

huangapple
  • 本文由 发表于 2014年7月12日 02:37:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/24704339.html
匿名

发表评论

匿名网友

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

确定