2

I installed goclipse in my eclipse, and setup the preferences as follows :

Preferences->Go->Tools

ProjectExplorer

Now when I create a new GoFile (HelloWorld.src), the file is saved in D:/GO/TestProject/src. But when I build the same file, the bin and pkg folders are empty and hence when I run the file the following error comes :

resource does not have a corresponding go package

Unable to run the code because of this error.

Shreya Srivastava
  • 41
  • 1
  • 4
  • 11
  • Put your `HelloWorld.go` into a folder under `src`, e.g. `src\hello\HelloWorld.go`. And you must start it with `package main` for it to be a runnable program. – icza Nov 25 '16 at 12:34

1 Answers1

0

Your project path should be D:\GO\src\TestProject in order to match the workspace expected as described in https://golang.org/doc/code.html

Then, your GOPATH should point to D:\GO (NOT ...\src) The go tool will automatically use $GOPATH/src, $GOPATH/bin or $GOPATH/pkg when appropiate for each case.

And as icza pointed out, your program should have a package main statement on the top of your go file to be recognized as an executable, unless you want to create a package, in that case, you should name your package as you want.

peiiion
  • 308
  • 2
  • 4
  • But when I add a new project the default location for the project comes as D:/Go and Not D;/go/src/TestProject But when I change the location to d:/Go/src/testProject the bin and pkg folders are not made and the Go file is not build. – Shreya Srivastava Nov 28 '16 at 06:09
  • I'm not sure, but i think the default location for a project is based on the Workspace configuration from Eclipse. About your compilation problems, can you provide the output for the `go build` or `go install` commands so we can see what's the problem and why the pkg/bin folders aren't being created? – peiiion Nov 29 '16 at 14:48
  • Did you check if bin and pkg folders where created in `D:/Go`? (Not `D:/Go/src/testProject`) – BrunoMedeiros Nov 29 '16 at 18:12