Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

gps doesn't handle directories with multiple packages #114

Closed
adg opened this issue Jan 19, 2017 · 4 comments
Closed

gps doesn't handle directories with multiple packages #114

adg opened this issue Jan 19, 2017 · 4 comments
Labels

Comments

@adg
Copy link
Contributor

adg commented Jan 19, 2017

A common idiom for packages with generated code is to include a file named something like gen.go that contains

package main

// +build ignore

...

These are then invoked with go generate. When doing a gps.ListPackages, the analysis of that package will fail with a *build.MultiplePackageError.

We need to be able to handle this. Should build ignore be handled specially?

@adg
Copy link
Contributor Author

adg commented Jan 19, 2017

@freeformz points out that this issue is not specific to ignore, although it is the most common.

@jessfraz
Copy link
Contributor

yeah we hit something like this too: sdboyer/gps#147 idk if related I had a generate build ignore file in a dir too

@sdboyer
Copy link
Member

sdboyer commented Jan 19, 2017

I actually did write special handling for this because of this idiom, and it should be working now. The problem, as someone just recently raised in the gps queue (sdboyer/gps#138), is that it doesn't work if there's > 1 file with package main and // +build ignore.

I definitely want proper support for this idiom, which means making it work no matter how many such files exist. As that issue describes, there's a hack we could implement to fix things "for now," though doing it properly is part of a larger planned refactor.

What's interesting about this case, and what I don't feel like I there's an obvious right answer to, is whether the imports from such main/ignored files should be included in analysis.

@jessfraz jessfraz added the bug label Jan 23, 2017
jessfraz pushed a commit that referenced this issue Jan 24, 2017
This fixes windows path errors (#103), and ignore-d main files (#114).
@sdboyer
Copy link
Member

sdboyer commented Jan 24, 2017

Should be all fixed up now

@sdboyer sdboyer closed this as completed Jan 24, 2017
zbintliff added a commit to zbintliff/dep that referenced this issue Mar 3, 2017
This fixes windows path errors (golang#103), and ignore-d main files (golang#114).
krisnova pushed a commit to krisnova/dep that referenced this issue Apr 21, 2017
ibrasho pushed a commit to ibrasho-forks/dep that referenced this issue May 10, 2017
This fixes windows path errors (golang#103), and ignore-d main files (golang#114).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants