This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
Change Identify API to accept only an io.Reader #322
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements a
"headerReader"
which caches all reads, and returns anio.MultiReader
so we can return a reader which will read from the same point in the input stream.This is particularly useful for the
Identify
function, which can now just accept anio.Reader
and not require anio.Seeker
which is somewhat unnecessary. Also, it will also always return the Reader despite the error which the caller can then read from as normal.On reflection it may be useful to still support
io.Seeker
's in another function, maybe these changes should be moved somewhere else. It is more useful for files because you can still continue to use the*os.File
instead of the more restrictiveio.Reader
.Also includes some tests for the mentioned functions.
This PR is based somewhat off the discussion in #317. I like this package and want to shift some of my projects that have a less clear API to using this. As an alternative, maybe if we expose the
formats
map, I can just implement this in a separate project.