{"repo":"gabriel-vasile/mimetype","free":true,"listed":false,"github":"https://github.com/gabriel-vasile/mimetype","clone":"git clone https://github.com/gabriel-vasile/mimetype.git","description":"A Go package for media type and file extension detection, based on magic numbers","language":"Go","stars":2008,"topics":["magic-numbers","sniffing","mime","media-types","detection","mimetype","golang","go"],"license":"MIT","category":"dev-tools","readme_excerpt":"mimetype A package for detecting MIME types and extensions based on magic numbers Goroutine safe, extensible, no C bindings Features - fast and precise MIME type and file extension detection - long list of supported MIME types - possibility to extend with other file formats - common file formats are prioritized - text vs. binary files differentiation - no external dependencies - safe for concurrent usage Install Usage See the runnable Go Playground examples. Caution: only use libraries like mimetype as a last resort. Content type detection using magic numbers is slow, inaccurate, and non-standard. Most of the times protocols have methods for specifying such metadata; e.g., Content-Type header in HTTP and SMTP. FAQ Q: My file is in the list of supported MIME types but it is not correctly detected. What should I do? A: Some file formats (often Microsoft Office documents) keep their signatures towards the end of the file. Try increasing the number of bytes used for detection with: If increasing the limit does not help, please open an issue. Tests In addition to unit tests, mimetype tests compares the library with libmagic) for around 50 000 sample files. Check the latest comparison results here. Benchmarks Benchmarks are performed when a PR is open. The results can be seen on the workflows page. Performance improvements are welcome but correctness is prioritized. Structure mimetype uses a hierarchical structure to keep the MIME type detection logic. This reduces the number of ca","default_branch":null,"files":null,"tree":[],"storefront":"/r/gabriel-vasile","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/gabriel-vasile/mimetype/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}