go-lang-plugin-org / go-lang-idea-plugin

Google Go language IDE built using the IntelliJ Platform
https://plugins.jetbrains.com/plugin/5047
Other
4.56k stars 570 forks source link

Choose GOROOT before GOPATH when selecting libraries #2839

Open siennathesane opened 7 years ago

siennathesane commented 7 years ago

Call a standard library and have the plugin autodetect which to import. In this case, I typed runtime.GOOS and let the plugin add the import.

The plugin would add "runtime" from the GOROOT standard library, not my GOPATH.

Because I have the core Go language (and lots of it's ecosystem) imported into my GOPATH (for language development), I can recursively import my local Go implementation. So when I typed runtime.GOOS, the plugin defaulted and imported "github.com/golang/go/src/pkg/runtime". I didn't notice it (off screen import) first, and when I went to compile it, it threw this error on Windows:

>go build
utils\log.go:13:2: C source files not allowed when not using cgo or SWIG: alg.c atomic_amd64.c callback_windows_amd64.c
cgocall.c chan.c closure_amd64.c complex.c cpuprof.c float.c hashmap.c iface.c lock_sema.c mcache.c mcentral.c mem_windo
ws.c mfinal.c mfixalloc.c mgc0.c mheap.c msize.c print.c proc.c rune.c runtime.c signal_windows_amd64.c slice.c symtab.c
 thread_windows.c traceback_x86.c
dlsniper commented 7 years ago

@zolotov the order of priority should be:

zolotov commented 7 years ago

@dlsniper no, it shouldn't. It is the order of roots for import path resolving. It has nothing to do with an order of import paths for qualifier resolving.

@mxplusb plugin doesn't add any import silently, it doesn't even try to autodetect which to import. In case you have several package with the same name, you'll see following popup when you try to auto-import runtime. Notice that SDK's one is the first in the list.

screenshot 2016-12-05 13 41 03

So either you have provided not exactly steps to recreate the issue or you just have no the runtime package attached to the project. Please describe steps to recreate the issue more accurate and attach .idea directory of you project.

dlsniper commented 7 years ago

@zolotov I've meant as according to how the go tool will search when compiling, if it helps for any priority weighting or as such.