can't find correct package when the folder's name is as same as package
templexxx opened this issue · 15 comments
-
Plugin version (or commit hash): 0.13.1924
-
IDE name and version: intellij idea 2016.3.1
-
Java version: 1.8.0_73
-
OS name and version: macOS 10.12.2
-
What are you trying to do?
I have two path as my GOPATH: A & B
and A/src/abc/d's package name is d
B/src/abc/d has three folders,every folders has its package name
I write "abc/d" in my golang import
-
What would you expect to happen?
what I want is A here, but it's B in fact -
What happens?
have a error: "no buildable go source files".
what's the content of qbox.us/fop
package? Does it contain go files? Are all files are matched to build target constraints?
You cannot import directory without go files, you just can't compile it.
Please provide more details on what exactly you're considering as a bug and explain step by step how to recreate this or attach a project example.
yes I can't. the wrong one has a folder, and it's name is fop, no go files under it. the right one has a folder name fop too, and go files under it. What I want is idea can import the right one but not the wrong one, but it always point the wrong one and tell me the import has an error
you can recreate it :
- add two paths as GOPATH
- add a folder under each path's src(folders' names are same), for example the folder name is "fffff"
- one folder has go files under it, and all go files belong a package. the package name is same with the folder name(fffff)
- the other folder has no go files under it, but some folders under it. and these folders have go files, these go files's package names are same with folders.
- when you create a new go file, and want to import fffff. it should be the fffff package but idea can't find the right package, it always show me the fffff folder.
sorry for my poor English, do I make it clear enough?
Thanks a lot. It's clear to me now. File an issue for Gogland: https://youtrack.jetbrains.com/issue/GO-3604
I've tried to recreate the issue and go
cannot build this. It says:
/usr/local/Cellar/go/1.7.3/libexec/bin/go run /Users/zolotov/tmp/gopath/src/github.com/dlsniper/go-metrics_backup/a.go
a.go:3:8: no buildable Go source files in /Users/zolotov/tmp/gopath/src/github.com/dlsniper/go-metrics_backup/root1/src/go3604
So IDE inspection works right. You should reorder your GOPATH entries to make it work
I can compile it, it means go build can find the right package, and atom can find the right package too.
There is no package name "fop" in this folder, how can Idea think the folder is what I import? What I need is package not folder, and what I write in import is package's path, not a folder path.
my GOPATH order is work well, but I found GOPATH's order in Gogland is different with my GOPATH. I try to do some moving, but nothing changed.
my GOPATH order is work well, but I found GOPATH's order in Gogland is different with my GOPATH. I try to do some moving, but nothing changed.
Show me the screenshot and tell me what order of paths you want to archive
What I need is package not folder, and what I write in import is package's path, not a folder path.
This is not how imports work. Imports point to folders (import path), particular qualifier expressions point to package.
Recreated, thanks. Gogland and the plugin reorder GOPATH taken from environment. Wil be fixed in the next Gogland EAP.
As a workaround: disable using GOPATH from environment and add all needed GOPATH entries manually.
I have done these, and work well.
Thank you!
Thank you. It's really great catch.