Closed jsfr closed 3 years ago
I'm not tracking what's going on with dep, but I'll have a look at it and tell you more about the gocode <-> dep situation. Will try to do so later today, hopefully won't forget about it.
Well I took a brief look. Seems like dep doesn't do any custom building. It relies on go tool and gocode should support everything go tool supports. Maybe. The main question to answer is where are the compiled libraries reside. Gocode pulls info only from compiled libraries or the currently edited package. Local autocompletion should work always, but when it comes to imported party packages it's important to make sure gocode finds the right binaries. What exactly doesn't work in your case?
So yeah as you're saying what doesn't work is exactly trying to autocomplete imported 3rd party packages which have been added to the project using dep
instead of go get
.
I think it may be some misconfiguration on my side though.
I've tried using gocode's autocompletion with Neovim and VS Code. For code all I have to do is download the Go extension and autocompletion works just fine in the project.
However for Vim I'm trying to use https://github.com/zchee/deoplete-go to get gocode working with Deoplete and here it doesn't seem to work :(. So probably this is just me no being able to figure out the right setup.
I'll continue to play around with it and write here if I make it work :)
@jsfr dep just inserts things in the vendor
directory so it should work if the vendored package is installed - gocode relies on the compiled .a
files for imported packages.
Maybe Neovim and VS Code are using the autobuild
option from https://github.com/nsf/gocode#options
I also encountered this problem. My temporary solution is: go build -i in the project path.
I just encountered this in my own project and even though I have .a
files generated under the /pkg
path gocode still seems to fail with the autocomplete.
emacs gocode dep not work
This issue isn't emacs specific, but are the arguments being passed incorrectly to gocode in the emacs gocode autocomplete? go build -i
does fix it temporarily (or running go install
on the 3rd party deps that I added using dep ensure
) but that's not a solution I'd like to support long term. The arguments are being passed in https://github.com/nsf/gocode/blob/master/emacs/go-autocomplete.el#L101 . I'm not super familiar with the arguments that gocode takes.
I managed to get this working by setting this flag:
gocode set autobuild true
The docs says this is an experimental feature.
My setup was as follows:
echo -e "package main\nfunc main(){}" > main.go && dep init && dep ensure -add github.com/gorilla/mux
main.go
and try auto completion for router (does not work):
package main
import ( "net/http"
"github.com/gorilla/mux"
)
func main() { router := mux.NewRouter() router.hand // Autocomplete here http.Handle("/", router) }
4. Enable autobuild:
`gocode set autobuild true`
5. Try autocompletion (works):
```go
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
router.Handle(path, handler) // Autocomplete here
http.Handle("/", router)
}
@palsivertsen try to run go install ./vendor/...
between 2 and 3 steps
@kovetskiy That seems to work as well, even with gocode set autobuild false
When using https://github.com/golang/dep in a project all dependencies are placed in the project root under
vendor/[url]/...
is it possible to get gocode to see these and autocomplete them?I realize
dep
is still an experiment, but I thought there might be a way since it's the official one. Still, I haven't been able to make it work either using thelib-path
orpackage-lookup-mode