A powerful Go library for MIME type detection using glob patterns, magic number signatures, XML namespaces, and tree magic.
mimemagic is a Go library for detecting MIME types of files using multiple methods like glob patterns, magic number signatures, XML namespaces, and tree magic. It solves the problem of accurately identifying file types by leveraging the XDG shared-mime-info database, ensuring reliable detection across various file formats.
Go developers building applications that require file type detection, such as web servers, file upload systems, or content management tools.
Developers choose mimemagic for its comprehensive detection methods, high performance, and pure Go implementation without external dependencies, making it a robust and efficient alternative to native tools.
Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, XML document namespaces, and tree magic for mounted volumes, generated from the XDG shared-mime-info database.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Combines glob patterns, magic signatures, XML namespaces, and tree magic per the XDG specification, ensuring accurate identification across diverse file types, as detailed in the README with 1003 MIME types and 493 magic signature tests.
Benchmarks show average detection times of 13 μs for Match(), with even faster glob-based matching, making it suitable for high-throughput file processing applications, as verified in the provided benchmarks.txt.
Has no external dependencies or C library bindings, ensuring easy integration and cross-platform support without additional setup, highlighted in the features as 'all in native go'.
Includes 1003 MIME types with descriptions, acronyms, aliases, extensions, and icons, providing detailed metadata for enhanced file analysis, as listed in the README's feature breakdown.
The main branch is GPL-2.0-or-later due to derived work from shared-mime-info, which may restrict use in proprietary projects; the MIT branch requires manual handling of a database file, adding redistribution hurdles.
For applications only needing file extension matching, the extensive detection methods and large database introduce unnecessary complexity and increased binary size, as it's designed for comprehensive sniffing.
Relies on the shared-mime-info database, so updates or custom MIME types require regenerating definitions using the included XML parser, which adds setup steps and potential maintenance overhead.