Go language configuring - eclipse

I need to do a work for my university and I choose to do it using the Go language. Yesterday I installed the .msi and setted the variables to:
GOPATH = C:\Users\Gustavo\goprojects (this is the folder that I want to place all my Go projects)
GOROOT = C:\Go\
PATH = C:\Users\Gustavo\goprojects\bin
After this, I installed the GoClipse plugin on my Eclipse and created a new project into the goprojects folder. Then, I created another folder in the src folder, and a .go file into this folder.
Now is my problem. When I started to write some code, everytime that I try to auto complete my code, Eclipse shows me an error and I was searching on google and found that I need to install one project from GitHub called gocode.
So I want to know where do I need to install it and how can I import it to my project.
P.S.: I am using Windows 8.1, I have git installed and the link of gocode project is: https://github.com/nsf/gocode

I solved my problem doing this steps:
Downloaded the gocode to the src folder. (The path: C:\Users\Gustavo\goprojects\src\github.com\nsf\gocode)
In the Eclipse, do this: Window -> Preferences.
Open Go option in the left menu then click Tools.
In the gocode path I set C:\Users\Gustavo\goprojects\bin\gocode.exe
And thats it! It works now.

Related

Golang on eclipse: "Resource doesn't have a corresponding Go package" on Mac

As stated in the title, I have a problem running the Golang code on Eclipse. I'm currently using Mac, and I installed go by using homebrew.
Currently, the folder where go is installed is as follows.
/usr/local/Cellar/go/1.5.2/..
and after running Terminal and typing open ~/.bash_profile I added the following.
export GOROOT="/usr/local/Cellar/go/1.5.2/"
export PATH=$PATH:$GOROOT/bin
Am I still missing something else?
PS If I run the code using Terminal like go run main.go, I have absolutely no problem. The problem must be due to some misconfiguration in Eclipse.
I had the same error. Putting the source file under a sub-folder in src fixed it.
Go to 'Run Configurations' -> Filter with Go Application -> select your project and then click the Environment tab, then click on select button and tick the GOPATH environment. select apply and then Run.
I had the same problem and I did two things to solve it:
I opened Run configurations, filtered using "Go" and created a new configuration (right click on "Go Application" as a result of the filter). In the Environment tab added a new variable: GOPATH = [path to your workspace].
I had .go files right under src folder, and this is wrong. I created a folder under src folder and moved .go files to that folder.
The first step could be replaced by creating a system environment and adding it to the list using the "Select" option instead of creating a new one. I prefered to create a new one so I can run differente projects in the same laptop without having to change the value of the system environment.
Because the executable path is not right.
GoClipse compiles source into $project/bin, so we must set GOPATH = $project
Select project > Alt+Enter > Go Compiler > Use project specific settings > Eclipse GOPATH
In my case of wiki tutorial, GOPATH = :/home/sovann/go/wiki.
Then the IDE is able to locate /home/sovann/go/wiki/bin/main

How to open the workspace folder from within Eclipse

My Eclipse has a project open which is inside a workspace folder.
Can I open the folder somehow from within Eclipse like you can in Visual Studio where you simply right click a project and press the "Open Containing Folder"?
There is a plugin that offers the functionality that you're seeing (and a little bit more) called, StartExplorer Eclipse Plug-in.
It's available here:
http://basti1302.github.io/startexplorer/
StartExplorer's github repo is here: https://github.com/basti1302/startexplorer
You install it by going to Help -> Install new software -> (add the update site url and install)

How to run a GO project in eclipse with goclipse installed

I have installed goclipse in my eclipse and created a new go project.
Now this is what I have:
And I have hello.go looks like this:
package main
import "fmt"
func main() {
fmt.Println("Hello")
}
Then I press run button, or right click the file hello.go, and then run, it gives nothing. Besides, it is also empty in bin folder.
Then I press run configurations button, almost empty there with only a project name. it gives:
Given Go package not found.
This is my Preferences for Go:
I noticed that both GOROOT and GOPATH are different from those listed in explorer, but once I changed them to C:\Go\src\pkg or C:\Go\src, the Apply and OK button becomes disabled. Besides, I don't have C:\Go\src\pkg folder either.
I can go install or go build in command line, but I would like to use eclipse for another much larger project. It's windows 7, and the eclipse version is Luna Service Release 1 (4.4.1). Thank you.
EDIT: Now I have the following configurations, and it works fine:
Go is installed at c:\Go
in Preferences: GOROOT:C:\Go, GOPATH: C:\Users\Tiina\go_workspace
The rest in Preferences is filled in automatically.
helloTest project is located at C:\Users\Tiina\go_workspace\src\helloTest
hello.go is located at C:\Users\Tiina\go_workspace\src\helloTest\hello.go
Maybe because I create a project from existing code, and there was something left behind, it automatically adds another GOPATH, in Preferences delete it.
If GOROOT refers to where go is installed (C:\Go), then you need to make sure that:
GOPATH differs from GOROOT (it is important, because GOROOT/[src|pkg|bin] are folders for the Go language itself, not for your own sources)
GOPPATH points to a folder under which all your different Go project will reside (for instance C:\Users\yourName\Go: that defines a workspace)
your eclipse project is created in GOPATH\src\myproject
See "How to Write Go Code" to make sure that your installation and project sources respect the expected organization.
The OP Tiina reports in the comments:
Now it works, but I noticed two things odd.
First what I did: I move helloTest folder into C:\Users\Tiina\go_workspace\src, so now it is at C:\Users\Tiina\go_workspace\src\helloTest.
Then I create project from existing code. Nothing else changed. Now I have two GOPATH in explorer, one is C:\Users\Tiina\go_workspace\src, the other one is C:\Users\Tiina\go_workspace\helloTest\src.
The latter one did no exist at the beginning
I suspect what goclipse does is define one GOPATH per project (or complete the existing GOPATH).
If you create or import a project, it will define/complete GOPATH in <that project/src>
If you hello.go is within that <that project/src/> folder, then it should build and work as expected.
The user guide "project structure" of goclipse mentions:
The project location is not part of any GOPATH entry.
In this case the project location will implicitly be added as an entry to the GOPATH, and a Go workspace structure with the bin, pkg, and src directories will be used in the project.
Note that the project's implicit GOPATH entry will only apply to the source modules in that project. It will not be visible to other Goclipse projects (unless the entry is explicitly added to the global GOPATH).
In the src folder you can create Go source files that will be compiled into a library package (and placed into pkg), or into an executable (and placed in bin)
Here's what one needs to do. One must always follow GO's convention of the directory structure. In eclipse, once a new project is created just create a "new folder" under the src directory by right clicking on the src folder. And now underneath this folder create a new GO file. I had issues running this on my MAC but by following the above steps was able to resolve.
Vishal (www.vishalpandya.com)
Please respect the fact, that if you change GOPATH while working in Eclise/GoClipse, you will have to Quit/restart Eclipse in order to Eclipse have the new environment variables to be reread.

how to import nodejs projects into nodejs eclipse in mac

I have cloned a project and try to load into nodejseclipse(mac) as file system or existing project. but it does load only root folder js files. it does not load all folder structures into eclipse. can you please help me on this.
You need install nodeclipse, first.
npm install -g nodeclipse to install it
Go to your folder, nodeclipse -g to generate nodeclipse project setting.
Open it from Eclipse "import from other projects".
It is not quite intuitive, but the following worked for me.
Move the project into the workspace directory. Then:
File > New > Project ...
Under Nodeclipse select Node.js Project and next >.
Under Project name: type the same name as the project you are importing and press Finish.
Now you should have the project visible in the Package Explorer.
To make .* files visible press the small arrow in the Package Explorer (top right) > Filters ....
Deselect .* resources > OK.
File -> New Project -> Node.js Project -> Project Name (Give some relevant name)
Next click on "Use default location" checkbox to check it off.
Next browse to the location where project has been cloned/exists
Finish.
Created a project folder in eclipse. Dragged the source and drop into project folder in eclipse. and then linked the source folder

Eclipse: Cannot find project in Project Explorer

I am using Eclipse Juno SR1 Java EE, and checked out code from SVN as an Eclipse project. I am able to click on files in the project to verify everything was ok. The next time I rebooted, I can't see the project in the Project Explorer window.
A few things I checked: The menu item Project > Open Project is greyed out, indicating there are no closed projects. The project's file tree exists in my workspace. Eclipse won't let me create a new project with the same name because one already exists.
This is my first time using Juno, is there some new control that hides projects from view?
"File -> Import -> General -> Existing Projects Into Workspace"
"File -> Import -> Android -> Existing Android Code Into Workspace" doesn't do what you're trying to accomplish (been there...).
Assuming the above lines mean what they say, the first tells Eclipse to recognize what you're importing as an official Project. The 2nd tells Eclipse that you're importing only the code, not the Project itself.
Sometimes it's just because .project file is missing. If you have any other project, copy its .project file and paste inside the main folder of the project you're trying to import.
Try starting with the clean option in command line, maybe that should fix it
eclipse -clean
try
file -> switch workspace -> other
and tell eclipse where your workspace is
I was facing the same problem with RAD. What I did was:
imported only those projects which were deployed locally in my portal server.
Did a clean build.
Started the server.
It worked for me. Able to access my application. Rest of the projects which were not deployed as part of my local portal server, I will import them on need basis later.