GoClipse / goclipse

Eclipse IDE for the Go programming language:
http://goclipse.github.io/
Eclipse Public License 1.0
841 stars 290 forks source link

Incorrect path value set to GOPATH, even when right checkboxes are selected in Eclipse #232

Closed rxa1031 closed 7 years ago

rxa1031 commented 7 years ago

submitting an issue: Incorrect used path for GOPATH even when right checkboxes are selected in Eclipse. Please refer to the uploaded image. Even though the checkbox "Also add project location to GOPATH, if it is not contained there already" is checked, yet GOPATH variable is not updated with the desired path. Hence in my case it keeps on pointing to C:\EclipseWorkspace\src and not to C:\EclipseWorkspace\Go\src

incorrect_gopath

This leads to various issues and hence the code cannot be executed: Even after creating the right hello.go file (Command source file -> Empty main function) and then adding hello world code to it, the code cannot be executed. creating_hello go This is because "Run -> Run Configurations... -> Go Application -> Go -> Main -> select... button -> Select go main package window" is empty. empty_select_go_main_package

I want to have separate / different folders for different projects. If the paths are set correct then every project folder can have folders like bin, src etc. and the generated executable will be easier to find.

Please refer to below images which inform folders inside the EclipseWorkspace directory and where files are downloaded by GO.

Go installation path: go_executables

EclipseWorkspace and the project GO workspace

Folders automatically created by go (and files were downloaded inside them).

(Not sure whether these folders were created on executing commands like: go get golang.org/x/net/html go get golang.org/x/net/websocket go get golang.org/x/text/encoding go get golang.org/x/crypto/ssh/terminal )

repository_default_download_location

Folder where executables like gocode, guru, godef etc. are downloaded: default_bin

Regards, Rajeev

rxa1031 commented 7 years ago

I have come up with a work around, which will have to be done for every project. For below explation, it is considered that Project name is "Go" and the folder absolute path is "C:\EclipseWorkspace\Go". Below are the steps:

  1. Open Eclipse, traverse to Windows -> Preferences -> Go Change GOPATH to point to the project directory (inside EclipseWorkspace) that is being used. For the discussed project (whose images are uploaded) this path is "E:\EclipseWorkspace\Go". Click apply button.

  2. Now open tools (under Go) and click one by one on the three download buttons (related with gocode, guru and godef). Click Apply and the OK buttons

  3. Exit Eclipse

  4. Open CMD.EXE (as I am using Windows 7 / Windows 10 as OS)

  5. Execute following commands one by one (I have go 1.7.4 installed at location C:\Go):

SET GOPATH=C:\EclipseWorkspace\Go

go get golang.org/x/net/html

go get golang.org/x/text/encoding

go get golang.org/x/text/encoding/charmap

go get golang.org/x/text/encoding/htmlindex

go get golang.org/x/text/transform

go get golang.org/x/crypto/ssh/terminal

  1. Open Eclipse and then build project.

  2. Goto Run -> Run Configuration... then select "Go Application" and click on "New launch configuration". Confirm that the project box has the text "Go" in it. Click "Select..." button that is associated with "Go package to build:". In the window that opes up, select "github.com/rxa1031/hello". Click Apply and then Run.

rxa1031 commented 7 years ago

Hi,

I found one more possible solution as stated below:

When creating project do not create it in the folder you set as your GOPATH, instead create the folder under %GOPATH%/src. Refer below image:

(I had to move the Workspace folder. On issuing command echo %GOPATH% on command prompt E:\GoClipseWsp string is returned)

goclipse_prj_creation

I still have the same setup as I had before, hence, I do not know whether various go get ... commands helped in any way.

As I am using Windows 7 as the OS hence I have changed the command for fetching packages (like: html, encoding, etc.) (I am assuming we call them packages) from: go get golang.org/x/crypto/ssh/terminal to: go get -u u -ldflags -H=windowsgui golang.org/x/crypto/ssh/terminal

Regards, Rajeev

bruno-medeiros commented 7 years ago

When creating project do not create it in the folder you set as your GOPATH, instead create the folder under %GOPATH%/src.

Sorry for late reply, but yes, this is essentially correct: if your GOPATH has the entry C:\FOO, then your Eclipse project cannot be located in C:\FOO\EclipseProject. It can only be located under C:\FOO\src (as in C:\FOO\src\EclipseProject). Alternatively the Eclipse project can have the same directory as the GOPATH entry (C:\FOO).

Also, don't set GOPATH as the same directory as the Eclipse workspace though, that can cause problems.