gocode icon indicating copy to clipboard operation
gocode copied to clipboard

Gocode not working for specifically one of my packages

Open haiyamicode opened this issue 12 years ago • 15 comments

At first it works normally, but just stopped working altegether for my specific package for a while. (for other packages that don't depend on it, gocode works normally) I used gocode -s -debug to see the problem, and it outputs a lot of these: Import path "github.com/phaikawl/wade/services/http" was not resolved it even outputs these silly things: Import path "fmt" was not resolved Import path "reflect" was not resolved I tried gocode drop-cache, but nothing changes. Full log at https://gist.github.com/phaikawl/4c562f7264070bd1dd5c. My full package code is at https://github.com/phaikawl/wade in case you want to test it.

haiyamicode avatar May 30 '14 11:05 haiyamicode

Well, if it can't find standard packages, most likely something is wrong with Go installation.

nsf avatar May 30 '14 12:05 nsf

What go env says?

nsf avatar May 30 '14 12:05 nsf

I think there's nothing wrong with Go installation, because it WORKS for ALL other packages that don't depend on that one package. I have been using it (in LiteIDE) for a long time and there's no problem. Anyways here is go env:

GOARCH="386"
GOBIN=""
GOCHAR="8"
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/phaikawl/Dev/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_386"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m32 -pthread"
CXX="g++"
CGO_ENABLED="1"

haiyamicode avatar May 30 '14 12:05 haiyamicode

I checked it on my machine by doing the same request you did in the log above for file: github.com/phaikawl/wade/promise.go. It works on my machine just fine. When I'm in NewPromise function and write h and do autocompletion it autocompletes it to http, then http members show up as well. See screenshot: wade

Although I'm on a 64 bit system, maybe that's the problem, but it seems unlikely to me. Maybe the package is not there for some reason? I clearly see mine:

[nsf @ ~]$ tree waytogo/pkg/linux_amd64/github.com/phaikawl
waytogo/pkg/linux_amd64/github.com/phaikawl
├── wade
│   └── services
│       └── http.a
└── wade.a

2 directories, 2 files

Maybe something is wrong with file permissions? Mine are fine:

[nsf @ ~]$ tree -pug waytogo/pkg/linux_amd64/github.com/phaikawl
waytogo/pkg/linux_amd64/github.com/phaikawl
├── [drwxr-xr-x nsf      users   ]  wade
│   └── [drwxr-xr-x nsf      users   ]  services
│       └── [-rw-r--r-- nsf      users   ]  http.a
└── [-rw-r--r-- nsf      users   ]  wade.a

2 directories, 2 files

There is no magic, if gocode says Import path "github.com/phaikawl/wade/services/http" was not resolved, then it wasn't able to find the file. And it looks in a lot of places. I asked you to print the environment, environment looks fine.

nsf avatar May 30 '14 13:05 nsf

It's weird. Is there any sort of temporary storage, optimization or something that could cause errors? (I tried running gocode drop-cache already).

haiyamicode avatar May 30 '14 13:05 haiyamicode

the vim view? i don't know if you have them enabled, but they could be the issue

kurojishi avatar May 30 '14 13:05 kurojishi

@kurojishi no i'm not using vim to code this thing.

haiyamicode avatar May 30 '14 13:05 haiyamicode

Gocode doesn't save anything on disk, except its config file, but as log shows, the lib-path option which may affect the package resolving is empty. So it's the default value. What go version are you using? go version

nsf avatar May 30 '14 13:05 nsf

I seem to have a somewhat similar problem. Were you perhaps using a release candidate of Go 1.3 @phaikawl ?

My specific thing:

➜  interpreter git:(master) ls -la
total 12
drwxr-xr-x  2 player player 4096 Jun 20 20:44 .
drwxr-xr-x 15 player player 4096 Jun 20 20:44 ..
-rw-r--r--  1 player player  588 Jun 20 20:44 interpreter.go
➜  interpreter git:(master) pwd
/home/player/go/src/bitbucket.org/aktau/ansible-go/interpreter

gocode debug output

2014/06/20 21:22:16 -------------------------------------------------------
2014/06/20 21:22:16 Import path "bitbucket.org/aktau/ansible-go/interpreter" was not resolved
2014/06/20 21:22:16 Gocode's build context is:
2014/06/20 21:22:16  GOROOT: /usr/lib/go
2014/06/20 21:22:16  GOPATH: /home/player/go
2014/06/20 21:22:16  GOOS: linux
2014/06/20 21:22:16  GOARCH: amd64
2014/06/20 21:22:16  lib-path: ""
2014/06/20 21:22:16 Import path "bitbucket.org/aktau/ansible-go/message" was not resolved
2014/06/20 21:22:16 Gocode's build context is:
2014/06/20 21:22:16  GOROOT: /usr/lib/go
2014/06/20 21:22:16  GOPATH: /home/player/go
2014/06/20 21:22:16  GOOS: linux
2014/06/20 21:22:16  GOARCH: amd64
2014/06/20 21:22:16  lib-path: ""

aktau avatar Jun 20 '14 19:06 aktau

@aktau Gocode doesn't parse source code of your package, it needs to be compiled.

nsf avatar Jun 20 '14 19:06 nsf

I mean gocode uses compiled libraries to resolve stuff, that is the file something like: /home/player/go/pkg/linux_amd64/bitbucket.org/aktau/ansible-go/interpreter.a

nsf avatar Jun 20 '14 19:06 nsf

@nsf it is indeed true that the package in question is not where it should be according to you:

➜  pkg  pwd
/home/player/go/pkg
➜  pkg  tree
.
└── linux_amd64
    ├── code.google.com
    │   └── p
    │       └── go.net
    │           └── websocket.a
    ├── github.com
    │   ├── ActiveState
    │   │   ├── tail
    │   │   │   ├── ratelimiter.a
    │   │   │   ├── util.a
    │   │   │   └── watch.a
    │   │   └── tail.a
    │   ├── cloudfoundry
    │   │   └── gosigar.a
    │   └── howeyc
    │       └── fsnotify.a
    ├── gopkg.in
    │   └── tomb.v1.a
    └── launchpad.net
        ├── goyaml.a
        └── tomb.a

Perhaps the behaviour of the go toolchain changed? I use go build -o go-app && ./go-app to build and test any go project I'm working on while I'm in vim.

What should I do to force Go to compile these things? I'm going to look around on the system to see if these packages are anywhere else...

UPDATE:

➜  pkg  sudo find / -name 'interpreter.*'
/home/player/go/src/bitbucket.org/aktau/ansible-go/interpreter/interpreter.go
/home/player/go/src/bitbucket.org/aktau/ansible-go/client/interpreter.go
/home/player/go/src/bitbucket.org/aktau/ansible-go/server/interpreter.go

It's getting stranger and stranger.

aktau avatar Jun 20 '14 19:06 aktau

go build doesn't install libraries, use go install.

nsf avatar Jun 20 '14 19:06 nsf

go build doesn't install libraries, use go install.

go install indeed does the trick. Yet, I haven't changed my edit-test cycle since I started coding in Go (when 1.1 was released), and I distinctly remember this not being a problem. I could Imagine that I did go install at some point in the project but I also (seem to) remember that I could autocomplete new methods very soon after I wrote them (after my first compile (go build -o go-app && ./go-app) of them). Am I hallucinating?

What do you use @nsf, do you always just go install?

aktau avatar Jun 20 '14 21:06 aktau

Yes, I use go install mostly. Occasionally go build to check syntax correctness, but not every often.

nsf avatar Jun 21 '14 04:06 nsf