Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gocode not working for specifically one of my packages #237

Closed
hami9x opened this issue May 30, 2014 · 16 comments
Closed

Gocode not working for specifically one of my packages #237

hami9x opened this issue May 30, 2014 · 16 comments

Comments

@hami9x
Copy link

hami9x commented May 30, 2014

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.

@nsf
Copy link
Owner

nsf commented May 30, 2014

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

@nsf
Copy link
Owner

nsf commented May 30, 2014

What go env says?

@hami9x
Copy link
Author

hami9x commented May 30, 2014

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"

@nsf
Copy link
Owner

nsf commented May 30, 2014

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.

@hami9x
Copy link
Author

hami9x commented May 30, 2014

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

@kurojishi
Copy link

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

@hami9x
Copy link
Author

hami9x commented May 30, 2014

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

@nsf
Copy link
Owner

nsf commented May 30, 2014

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

@aktau
Copy link

aktau commented Jun 20, 2014

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: ""

@nsf
Copy link
Owner

nsf commented Jun 20, 2014

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

@nsf
Copy link
Owner

nsf commented Jun 20, 2014

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

@aktau
Copy link

aktau commented Jun 20, 2014

@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.

@nsf
Copy link
Owner

nsf commented Jun 20, 2014

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

@aktau
Copy link

aktau commented Jun 20, 2014

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?

@nsf
Copy link
Owner

nsf commented Jun 21, 2014

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

@nsf nsf closed this as completed Dec 13, 2014
artnez added a commit to artnez/gocode that referenced this issue Aug 30, 2015
artnez added a commit to artnez/gocode that referenced this issue Aug 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@nsf @aktau @kurojishi @hami9x and others