github.com/daryldohner20/mimetype (go): Package mimetype uses magic number signatures to detect the MIME type of a file.  File formats are stored in a hierarchy with application/octet-stream at its root. For example, the hierarchy for HTML format is application/octet-stream -> text/plain -> text/html.   Pure io.Readers (meaning those without a Seek method) cannot be read twice. This means that once DetectReader has been called on an io.Reader, that reader is missing the bytes representing the header of the file. To detect the MIME type and then reuse the input, use a buffer, io.TeeReader, and io.MultiReader to create a new reader containing the original, unaltered data.  If the input is an io.ReadSeeker instead, call input.Seek(0, io.SeekStart) before reusing it.   Use Extend to add support for a file format which is not detected by mimetype.  https://www.garykessler.net/library/file_sigs.html and https://github.com/file/file/tree/master/magic/Magdir have signatures for a multitude of file formats.   Considering the definition of a binary file as "a computer file that is not a text file", they can differentiated by searching for the text/plain MIME in their MIME hierarchy.
Keywords: detection|go|golang|magic-numbers|media-types|mime|mimetype|sniffing