0

Everytime, when I try to run my Hello-world-program, I get an error message from Eclipse saying "Resource doesnt have a corresponding Go package." There is already a post about the same error message, but the provided solutions didn't help me.

The installation set the GOROOT automatically to "C:\Go\src" For my workspace I created a directory "D:\eclipseGo\workspace", and assigned it to my GOPATH variable.

Following picture shows my setup from the project explorer

enter image description here

As you can see, the GOPATH there points to the src-folder.

In the preferences (under "Go"), the GOROOT was set automatically. Unter Go-Tools I picked the path of the gocode.exe with the "Browse..."-button, and selected the gocode.exe, which was at "D:\eclipseGo\workspace\bin\gocode.exe". Below, the gofmt was set automatically.

That's all what I configured. Does anyone know, where the problem is?

KJaeg
  • 698
  • 3
  • 7
  • 23
  • Don't set GOROOT. And GOPATH should be `D:\eclipseGo\workspace`, with the `src` directory inside GOPATH. See [How to Write Go Code](https://golang.org/doc/code.html) – JimB Jun 15 '16 at 13:15
  • I didn't set GOROOT, it was set during the Go installation manually. After installing Goclipse, this was also detected automatically. After I created a Go-project, the GOROOT inside of the project was automatically fetched. If I type in `%GOPATH%` into the console, it is showing me `D:\eclipseGo\workspace`. In the Preferences under "Go" it is set to use the same value as the GOPATH environment variable, which also is displayed as `D:\eclipseGo\workspace`. I don't know why the picture is showing the `src`at the end of the GOPATH. – KJaeg Jun 16 '16 at 09:04
  • The `src` bit is added just for display purposes in the Project Explorer (yes, that is perhaps confusing). Also note, if you make changes to the GOPATH, the Project Explorer is not updated unless you press refresh (F5). This is a bug/limitation. – BrunoMedeiros Jun 17 '16 at 20:04

1 Answers1

0

Your project setup seems to indicate MyProject is not contained inside D:\eclipseGo\workspace, so you either need to move your project to a folder inside D:\eclipseGo\workspace\src, or alternatively enable the option "Also add project location to GOPATH, if it's not contained there already." in the project's GOPATH settings (note that this can be configurate globally or per-project).

The Project Explorer display above is misleading because the folder icons seem to indicate MyProject/src is a "source folder" and the files it contains are part of the GOPATH, when they are in fact not. I'm making a note to have this fixed in the next release, as well as the refresh bug.

BrunoMedeiros
  • 1,441
  • 12
  • 14