mimetype
mimetype copied to clipboard
Feature: Functions for specific doc types
First off, I want to say thank you for your hard work on this project! I'm transitioning my critical path code from h2non/filepath
to mimetype
due to your better support for MSO files. I did have a feature request though that would make my life much easier, and I'm assuming others as well:
filetype
has a few really nice aggregate functions that tell you if a file is a document, compressed, image, etc. Here's an example. I think with the tree structure you have, you could even make this dynamic by constructing the tree with something like namespaces. Or you could simply have a manual list of all the file types you support. Or even have a tag
field on your structure.
There's lots of options, but generally I'd love to see the ability to ask mimetype if a file is of a compressed type without having to hard-code a list of mimetypes that are compressed.
Something like:
mt := mimetype.Detect(buffer)
if mt.IsCompressed() {
// Do something
} else if mt.IsImage() {
// Do something else
}