nsf / gocode

An autocompletion daemon for the Go programming language
MIT License
5.01k stars 658 forks source link

Any further setups needed to get more intelligent completion? #496

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello, first of all thank you for maintaining this awesome project.

I'm using go-code on emacs with company-go.

For me, it works nice for standard libraries and local functions and variables, etc.

However I cannot get completion for imported packages from $GOPATH/src/.

For example, I want completion at this point, but it doesn't provide me any completion.

$GOPATH/src/example/example.go
package example

func Foobar() int {
    return 10
}

====================================
// trying to use package from here
package main

import (
    "example"
)

func main() {
    example.Foo|
}

Do I need more setups to get completion at this point?

Here's my settings.

.bashrc
export $PATH=$PATH:$HOME/git/go/bin:$HOME/go/bin
export $GOPATH=$HOME/go

.emacs.d/init.el
(require 'go-mode)                                                                                                                                
(require 'company-go)                                                                                                                             
(add-hook 'go-mode-hook                                                                                                                           
          (lambda ()                                                                                                                
            (add-to-list 'company-backends '(company-go))))  

Best Regards, Seonghyun Park

nsf commented 6 years ago

Install the package: go install example. Package binary needs to be there for gocode to notice it. Gocode works with binary packages only when it comes to imported packages.

ghost commented 6 years ago

Now, it works quite nice with new packages.

Thank you for your early response!