Wrong configuration of Goclipse in Eclipse

952 views Asked by At

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?

1

There are 1 answers

0
BrunoMedeiros On

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.