You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's no way at the moment to use Import or ImportDir to select all the files in package ignoring build constraints. There is the Package.IgnoredGoFiles field, but that does not extend to finding the dependencies of the ignored files, and so requires extra parsing steps.
One use case for this is in situations like App Engine: we want to select all the source files for an app, but not exclude source file that would be needed to compile a package in other/future versions of Go. So, we want to select files ignoring any go1.x tags.
why not just programmatically add all go1.x tags to
Context.BuildTags (or even Context.ReleaseTags)?
Ignoring all tags might not be what you want if you
just want to select files for future Go versions.
Adding all go1.x tags isn't sufficient because then you will reject current versions: I don't want to select for just a specific future version, but rather all possible versions from now into the future.
AFAICT, the only way to achieve that with the current API would be to repeatedly invoke Import with increasing sets of tags: go1.0-go1.6; go1.0-go1.7, go1.0-go1.8, etc. Fortunately, you can use Package.IgnoredGoFiles to determine when that is necessary at all, and Package.AllTags to determine the set of version tags you need to try. But it's still very hacky.
There's no way at the moment to use
Import
orImportDir
to select all the files in package ignoring build constraints. There is thePackage.IgnoredGoFiles
field, but that does not extend to finding the dependencies of the ignored files, and so requires extra parsing steps.One use case for this is in situations like App Engine: we want to select all the source files for an app, but not exclude source file that would be needed to compile a package in other/future versions of Go. So, we want to select files ignoring any go1.x tags.
/cc @dsymonds @adg
The text was updated successfully, but these errors were encountered: