6

After I updated GoLand from EAP 18 to EAP 19 my imports are red and these errors occur in each file:

Import errors

My $GOROOT and $GOPATH are the same as before. $GOROOT points to /usr/local/go. Files are buildable through shell but GoLand keep showing errors.

I am running GoLand on Mac OS with Go version go1.9.1 darwin/amd64:

GoLand (1.0 Preview) 1.0 EAP Build #GO-173.3727.24, built on November 16, 2017 GoLand EAP User Expiration date: December 16, 2017 JRE: 1.8.0_152-release-1024-b6 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Mac OS X 10.12.6

Ivan Aracki
  • 4,861
  • 11
  • 59
  • 73

5 Answers5

11

It looks like indexes are corrupted. File | Invalidate Caches should help.

  • 1
    doesn't help for me. Also have several projects that builds nicely but one of libs in import sections is underlined with red in IDE with the eroror that there is no buildable go files.. even with the fact that it is in vendor folder of each projects – Altenrion Jan 09 '18 at 10:04
  • Altenrion, then it makes sense to file an issue about it with diagnostic details such as IDE version, project structure and screenshots: https://youtrack.jetbrains.com – Alexander Zolotov Jan 09 '18 at 12:53
1

When File | Invalidate Caches doesn't help, deleting the project and checking it out again does did the trick in my case.

Macilias
  • 3,279
  • 2
  • 31
  • 43
1

If invalidating caches does not fix the problem for you, it can also be that the package has build constraints that prevent it from being built on your system. I was attempting to import golang.org/x/sys/windows/svc while using Goland on a Mac and it took me a while to realize why Goland was saying it didn't have sources files when clearly it did. All the files in the golang.org/x/sys/windows/svc package are constrained to only build on Windows.

Phillip
  • 643
  • 6
  • 15
1

One day I started to get this error on GoLand 2018.1

GOROOT & GOPATH where fine.

To fix that:

  • Opened File -> Settings -> Go -> GOPATH
  • Marked Index entire GOPATH

enter image description here

michaelbn
  • 7,393
  • 3
  • 33
  • 46
-1

Try these step:

  1. close the goland IDE.
  2. delete the .idea folder.
  3. start the goland IDE.