Configure Eclipse as Go IDE - windows

I've decided to use Eclipse (with the goClipse plugin) as my editor for go projects.
I already had go installed and (before choosing Eclipse) I had designated c:\go-workspace as my workspace.
I now want to configure Eclipse to use that workspace as my location for go work.
I plan to import various projects from github and create my own github account where I can commit changes, etc. All those imports will be under the src/directory, and this is in accordance with this article that seems to indicate it is best to have one go workspace with everything under the src/ directory: https://talks.golang.org/2014/organizeio.slide#9.
I'm having issues creating a go project in Eclipse.
I choose File > New Go Project and browse to c:\go-workspace.
I enter a project name in the dialog but I get a message saying that a directory already exists at the specified location and my only choice is to cancel.
I then tried creating a new Eclipse workspace but when Eclipse was finished it indicated it is a Java project.
How do I accomplish what I want to do? Or perhaps the "best practice" for what I want to do is something else.

Ok, you already decided to go for IntelliJ but maybe someone else might be interested in an answer though ...
I also had some fights with GoClipse but finally I got it working. The solution is to input the whole path (including the project name). So for example your GOPATH is (on Linux) /home/username/go and you want to create a project named "gopro" and want to place it in "/home/username/go/src/github.com/user" you need to type in the Eclipse window: "/home/username/go/src/github.com/user/gopro". Everything should work without any problems afterwards.

I could not find an answer to this question. I've decided to use IntelliJ with the golang plugin and this solution works wonderfully.

Related

Correct structure of Golang repository

I am starting in Golang development. Right now my boss gave me the repository of a project that other developer made, now he's gone of the company and I am not able to ask him some things related to it. Right now I have a confussion about the project structure that he pushed to the repo, the structure is the next:
|-MyApp
|--bin
|--pkg
|--src
|----api (the code of the app)
|----github.com
|----golang.org
|----gopkg.in
To me, it's exaclty as the estructure of the Go, 1.- in the repo should not be only the api folder?
If I go to the api folder and make go run main.go I get a message that some packages are not found even when they are in the folder, 2.-how I specify the packages in the go run command?
3.- Is a good practice to set this kind of structure for the golang projects? I see in the code that he exported the packages only with "package1", if I copy and paste the code of the app inside the golang workspace then I have to specify the name of the folder to export the packages, example: "myApp/package1" so there I have that doubt. Thank you
That all depends. There is not a single right way for everything.
It seems as if this repo decided to vendor everything, the whole GOPATH. That is okay but with the "modern" vendor folder today one would do it probably differently.
Never do go run. That's for toy programs only. Build your software with go build and go install. These command work on package path.
For everything else: Please see the official documentation https://golang.org/doc/code.html and stick to it (which means you should move stuff around a bit).

OpenFrameworks setting for latest xcode_How can I make a new project?

I started OpenFrameworks for fun :D
However, setting OF in Xcode is little bit confusing.
According to web search, just copy and paste Example and edit that project.
It is little bit uncomfortable since workspace location is restricted.
Now I am curious is there any tutorial which start with xcode - [new project]?(I mean xcode UI)
So I can make OF Xcode workspace anywhere I wanted.
A Link can be very granted.
Thanks for answer:D
PS. If you do not mind please attach answer as answer section, not in reply, so I can close this question.
I'm a bit confused on what you mean with workspace location is restricted, do you mean that the location where you can put your project is limited?
Generally all projects in openframeworks are being put inside the apps folder of openFrameworks. Technically it is possible to take a project out, but it's not recommended.
You can both have a structure like this:
openframeworks/apps/myApps/myNewSuperOfApp
or
openframeworks/apps/someProject/myNewSuperOfApp
Copying the example is one way of creating a new project, but a easier way (sometimes) is to use the project generator that you find in projectGenerator_osx
You do not want to create an empty project in xcode and, then add openframeworks to it. The projects that are generated with the project generator (or the examples) have a lot of settings that are needed in the xcode project for them to compile with openframeworks. It's not something that you easily can add to an empty xcode project.

Eclipse - bin Folder keeps creating itself

This is a long one, but please, bear with me. I really need help here.
I use Eclipse (latest version) to play with some programs of my own. During installation (?), it asked me where I'd like to put in my Workspace folder. I set it to default, but, not wanting to dig through Documents and such (I have my own Documents folder on another drive), I made sure that every project I have is condensed into one "Projects" folder, not in the Workspace. My "Projects" folder contains every program I've coded so far, from C# to Java, as well as the necessary tools, like the Eclipse folder.
It worked fine for me, until I decided I want to do another project. So, I navigated to my "Projects" folder, and then created it there.
Now for some reason, Eclipse treated the directory I navigated to as my project folder. As in, new folders like bin, src, etc. started popping up in my otherwise organized folder. Visual Studio does not have this problem, and actually creates a new folder for your project under whatever directory you set it to.
So I, in a 'Monday blues' move, went into Eclipse and deleted my project. Eclipse wasted no time in deleting my entire "Projects" folder and everything in it - including itself, apparently. Gah.
I quickly closed Eclipse, but it kept saying something about 'Saving Workspace' which I assumed meant "Don't close me yet, I'm still deleting your files."
I thought I was being sensible when I terminated it via the Task Manager. It stopped deleting my stuff, but out of the dozen or so programs, I only managed to save three.
Wanting to start over again, I deleted (what's left of) my Eclipse, so I can 'install' it again, and let it have its way of where to create projects and save my files, so that this doesn't happen again. Unfortunately, one folder keeps returning no matter how many times I delete it. The aforementioned bin folder, a name that needs at least two adjectives and the suffix "Of the Damned."
So, to summarize:
I lost majority of my programs.
I lost my Eclipse.
And folder 'Bin' keeps popping up.
And so I'd like to ask:
Can I recover my files?
How can I setup Eclipse so that it creates a new project folder when I create a new project instead of treating the directory as the project folder?
How can I permanently get rid of that haunted Bin folder?
If anyone an help out here, thank you so much. This has easily been one of my worst Mondays.
As of now, I have tried:
Restarting my PC (didn't work, Bin Folder is still there)
Downloading and running a new copy of Eclipse (didn't work either)
I have struggles also on my Eclipse for the past few weeks. I answer each of your question below, hope that helps.
Can I recover my files? - If your programs are not physically removed from disk, you can add it back when you have your Eclipse running
How can I setup Eclipse so that it creates a new project folder when I create a new project instead of treating the directory as the project folder? - Create your project by clicking File->New->Android Application Project (if android). Then input the application name,etc. Click Next and uncheck create project in workspace, from there you can have your own location or directory of your project.
How can I permanently get rid of that haunted Bin folder? - In may case, I downloaded a fresh copy of Eclipse. I used the adt bundle which can be downloaded here: http://developer.android.com/sdk/index.html
the sad news is, that Eclipse does not just delete the projects into the bin, like it would happen with the "delete" by clicking on the folder and manually deleting it. You could try with recovery software, but it is not an assurance it will work, or recover all your lost data.
For the more of it, in the Bin folder that is made automatically in any Java project, you get compiled classes which are what gets packaged/archived into any jars that are created.(I hope this makes sense, I couldn't find a better way to explain myself.)
For the set-up of Eclipse I would have a look at the page of Eclipse, maybe a forum, or a FAQ is there.
I for instance use Netbeans, which does from the start always create a new folder for the new projects.
I hope I could somehow help!Here a little link to a recovery software that has a good reputation: http://www.piriform.com/recuva
Kind regards,
DomExtra edit: Version Control is an awesome tool to save your buttex from trouble like this ;)

xcodebuild says does not contain scheme

I have a curios issue.
I have a project that I've worked on and always built from the XCode IDE, and it worked fine. Now I'm setting up Bamboo to build the project and as such am building it from the command line.
The issue is, if I check my code out of GIT and then use xcodebuild to build it it says that the scheme cannot be found, but if I open the project, it builds and if I then try to build it again from the command line with the same command, it works.
What magic is XCode doing when I open the project or am I doing something dumb, maybe excluding a file in my .gitignore that I shouldn't?
You are definitely on the right track with respect to the .xcscheme file -- I had this problem appear while setting up my own projects!
For posterity, or at least anyone getting here from a search, here are two versions of things -- the "I'm busy, so just the facts please" version and a more involved discussion and rationale. Both of these versions assume you are trying to build from a Workspace file; if you aren't then my apologies as this mostly applicable to workspace-based projects.
Condensed 'Fix-it' Version
The root cause is that the default behavior of Schemes is to keep schemes 'private' until they are specifically marked as shared. In the case of a command-line initiated build, the Xcode UI never runs and the xcoderun tool doesn't have its own cache of Schemes to work with. The goal is to generate, share, and commit the scheme you want Bamboo to run:
On a clean working copy of the code, open your Project's workspace.
Choose Scheme > Manage Schemes... from the Product Menu.
The list of Schemes defined for the project appears.
Locate the Scheme Bamboo is trying to run
Ensure the 'Shared' box is checked for that scheme and that the 'Container' setting is set to the Workspace and not the project file itself.
Click 'OK' to dismiss the Manage Schemes sheet.
A new .xcscheme file has been created in your project at WorkspaceName.xcworkspace/xcshareddata/xcschemes.
Commit this file to your repository and run a Bamboo build.
Deeper Discussion and Rationale
Xcode 4 introduced Workspaces and Schemes as a way to help try and tame some of the chaos that is inherent to dealing with the mechanics of wiring related Xcode projects, build targets, and build configurations together. The workspace itself has its own set of configuration data that describes each of the smaller 'boxes' of data it contains and acts as a skeleton for attaching .xcodeproj files and a set of shared configuration data that gets mirrored to each developer machine or CI system. This is both the power and pitfall of Workspaces -- there are 1) lots of ways in which one can get things configured 100% correctly, but put into the wrong container or 2) put into the correct container, but configured improperly thus rendering data inaccessible by other parts of the system!
The default behavior of Xcode 4 schemes is to automatically generate new schemes as projects are added to the Workspace file. Those of you that have added several .xcodeproj files may have noticed that your scheme list quickly becomes unruly especially as project files are added, then removed, and then readded to the same workspace. All schemes, autogenerated or manually created, default to being 'private' schemes visible only to the current user even when .xcuserdata files are committed with the project's data and configuration. This is the root cause of that cryptic build error Bamboo reports from xcodebuild -- Because Bamboo operates the build through the command line and not the Xcode UI, it doesn't have an opportunity for Schemes to get automatically generated and relies only on those that are defined in the workspace itself. Assuming you've configured Bamboo to build from a workspace using a command like this:
xcodebuild -workspace MyWorkspace.xcworkspace -scheme MyApplication -configuration Debug
xcodebuild goes looking for file <'scheme' Parameter Value>.xcscheme existing at <'workspace' Parameter Value>/xcshareddata/xcschemes.
Obviously there are bunches of ways in which one could configure both Bamboo and a workspace, so keep in mind that your unique configuration may not map 100% to what is presented here. The key takeaways:
Certain automated tasks the Xcode UI magically takes care of are not available via the Xcodebuild CLI.
You can attach scheme and build configuration data to many places in the 'container hierarchy' -- Make sure your data winds up in the right container (Workspace, Project, and/or Build Target)
Consider where in the container hierarchy the xcodebuild tool may be looking for configuration data; a great indicator of where it will start looking is based on the use of '-workspace' or '-project' arguments.
The 'Shared' box is already checked...now what?
I encountered this same issue on my own Bamboo instance; it turned out that the scheme that was committed in my repository was outdated and the latest version of the command line tools wasn't handling it gracefully. Since this existed previously, I took a look through the settings to make sure there wasn't anything glaringly custom about the scheme, deleted and recreated the scheme ensuring that I marked it as 'Shared', and recommitting the new .xcscheme file to the repository.
If everything looks good and rebuilding it doesn't solve the issue, double check that container setting -- it is really easy to get that scheme attached to the wrong container in the hierarchy!
Debug the issue like this:
xcodebuild -list
or if you are using a workspace (e.g. with pods)
xcodebuild -workspace MyProject.xcworkspace -list
If you scheme is not listed fix like so:
Most of the answers would suggest you to make your scheme shared using Xcode, then commit changes to repo. That works, of course, but only if you have access to source code and have rights to commit changes, and couple of other assumptions.
But there's a number of "what ifs" to consider
What if you just can't modify the Xcode project for some reason?
What if you create a new scheme automatically on CI server? This actually happens quite often. If you use test automation framework, like Calabash, you'll normally end up duplicating an existing target, which automatically duplicates a scheme as well, and the new scheme is not shared, even if the original scheme was.
Ruby & xcodeproj gem
I would recommend using xcodeproj Ruby gem.
This is a really cool open source tool that can help you to automate tons of Xcode-related tasks.
Btw, this is the gem used by CocoaPods to mess around with your Xcode projects and workspaces.
So install it
sudo gem install xcodeproj
Then write a simple Ruby script to re-share all the schemes, the gem has recreate_user_schemes method for that purpose
#!/usr/bin/env ruby
require 'xcodeproj'
xcproj = Xcodeproj::Project.open("MyProject.xcodeproj")
xcproj.recreate_user_schemes
xcproj.save
It doesn't just copy scheme files form user's folder to xcshareddata/xcschemes, it also creates those files first by parsing the pbxproj file.
Ok I know its 2 minutes later but I found another stack overflow that says the scheme has to be set to shared... Where does Xcode 4 store Scheme Data?
One common reason for the scheme to be missing is forgetting to push the commits to the origin. If you get a missing scheme message, you should first verify the scheme is shared, then verify you have committed the changes AND pushed them to the origin server.
I had this error while implementing CI.The Question above is identical to my problems except I am using Gitlab's own CI tool.You can check if there is any such file in Bamboo.
I solved it by making some changes to gitlab-ci.yml file.
After you hav made your scheme availabe by sharing. In Xcode Go to Products>Scheme>Manage Scheme and check share to share.
Changes
Set absolute path everywhere.
eg.xcodebuild clean archive -archivePath /path/to/your/project/build/testDemo -scheme testDemo | xcpretty
here you need to change /path/to/your/project/ with your path and testDemo with your project name.
I faced this issue and even if some of the answers here actually provide the solution, I didn't find it very clear. So I will just add one more. In a nutshell how to share a schema from excode.
Navigate to Product > Scheme > Manage Schemes
You will then be shown a list of schemes, with each denoted as being shared or not. Just check the ones that you want to share (it may be different ones for dev and prod builds)
Images taken from this article https://developer.nevercode.io/docs/sharing-ios-project-schemes
Got the same problem but during building with xcode as subproject of main one. Built subproject in xcode standalone - after that this error disappeared.
I want to add solution for my case related to this thread. This one is for you who clone existing project, with all the schemes you need are already being shared:
, with fastlane lanes correctly display all your lanes including all your schemes:
, but fastlane gym only show main schemes (not dev and test schemes):
The solution is to uncheck the shared option for schemes that not listed by fastlane gym and then check it again. It will generates .xcscheme for the schemes:
Now, if you check with fastlane gym, all the schemes will be listed:
Then you should commit those .xcshemes file to the repository, so other developer who clone the project will get the files.
For anyone with Xcode 11.4 trying to find "Shared" button on scheme, it's now moved into the individual scheme.
Select the scheme you want
Press "Edit"
Check the "Shared" box

Eclipse, import project but don't copy

I use Linux as primary operating system and I also have to work on a Windows virtual machine with Eclipse 3.7.
We're working with subversion but with Linux I'm happily using git-svn with Emacs+magit, which works great.
So I would like to be able to work on the same code from both OS, and only do the real version control management on Linux.
So I had the following thought:
1. share the directory with virtualbox
2. create the projects pointing to the shared directory
Well that doesn't work, because the dumb thing wants to copy everything.
So I tried to use virtual folders which seemed a good idea, but now some scripts are badly failing because they don't find the hard-coded paths.
So I don't know anymore what to try, any idea?
EDIT:
My last attempt in the last edit would not work, so I have a simpler question.
Given a git/svn/whatever repository checkout, why can't I simply tell to Eclipse create a project there without touching the files?
Is it so hard for Eclipse to create it's .project in that position?
And since there is clearly no "supported" way to do it, is there maybe any workaround?
From my experience, the stages are the following (using Indigo version):
1. Create new empty project
2. Click File->import->file system
3. in the import window import file system, check the files you want into the new project folder
4. Click on advanced in the import window and tick "create links in workspace"
The new project should contain links to the original directory.
Eclipse modifies and compiles source in its workspace. The first level of the workspace is the project directories, + a .metadata which is local only to that workspace instance. Traditionally, the workspace contains the projects it works on.
Eclipse also supports 2 linked modes. In one, when you create the project in the workspace you give it an absolute path to somewhere else on the file system. This is handy if you have eclipse projects in a git repo, for example.
In the other mode, you create the project in your workspace locally. Then you link your folders (source, resources, whatever) to somewhere else on the filesystem. This is useful for projects that don't want to save the eclipse specific files (.project, .classpath, etc) in their SCM.
You have to create a different workspace on each OS (there's no way around that). But you could create the projects in each workspace and link to the common location (I don't recommend it, but it would be do-able).
Same problem here and finally got a solution!
1) clone your repo but not directly to your workspace, in my case I used workspace2 instead of workspace.
2) On eclipse, import all the projects on workspace2, but don't mark the "copy files to workspace", so the source code is left on workspace2.
3) On git you will see changes appeared, on project.options files (only file date is changed) and in .path files (some lines changed its order). As all of them are irrelevant changes, reset the local branch discarding those changes.
Thats all, git sees no more changes and eclipse open the files properly!
I ran into a weird problem worth commenting here: after importing i went to "git gui" to see changes, and the first file changed was a "project.options" file that only changed its date but the diff was empty (as the content was unchanged). There is a bug on git that makes git gui enter on an infinite loop: while it detect changes on file and diff is empty, a rescan is performed, then the same change is detected and enter on a rescan loop.
There is a patch to solve this, but it was easier just to add a silly comment on that only file (not in all your project.options) and then "git gui" was happy again and i could reset the changes on the branch.

Resources