Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, XML document namespaces, and tree magic for mounted volu
Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, XML document namespaces, and tree magic for mounted volu
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.
The generated code in magicsigs.go, globs.go, treemagicsigs.go, namespaces.go
and mediatypes.go makes this a derivative work of shared-mime-info, and therefore falls under the
GPL-2.0-or-later license. See the discussion.
For an MIT licensed branch with the generated code removed, please see this. Providing a hypothetical permissively licensed freedesktop.org.xml file for parsing is still required, to redistribute the compiled executable with that license, however.
The library:
go get github.com/zRedShift/mimemagic/v2The CLI:
go get github.com/zRedShift/mimemagic/v2/cmd/mimemagicSee the Godoc reference, and cmd/mimemagic for an example implementation.
The library:
…The CLI:
…See Benchmarks. For Match(), the average across over 400 completely different files (representing a unique MIME type each) is 13 ± 7 μs/op. For MatchGlob() it's 900 ± 200 ns/op, and for 12 ± 7 μs/op MatchMagic().
No open issues yet, or sync has not completed.