go-mime-lib-compare

command module
v0.0.0-...-80e2729 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2019 License: MIT Imports: 13 Imported by: 0

README

go-mime-lib-compare

A simple project to compare different Go projects/packages that detect MIME types.

Libraries

Library Implementation Stars Contributors
http.DetectContentType Pure Go
gabriel-vasile/mimetype Pure Go stars contrib
zRedShift/mimemagic Pure Go stars contrib
h2non/filetype Pure Go stars contrib
vimeo/go-magic/magic libmagic stars contrib
rakyll/magicmime libmagic stars contrib

Building

Dependency:

Some go packages for MIME type detection are libmagic wrappers.

$ brew install libmagic

Build:

$ go build

Use:

$ ./go-mime-lib-compare > out.md

See comparison results.

Summary
  • gabriel-vasile/mimetype is written in pure Go and has good detection capablities and uses a hierarchical detection structure.
  • Go wrappers of libmagic have the most accurate MIME type detection. However it entails use of cgo. Further, libmagic is not threadsafe and hence Go wrappers will have to use either sync.Mutex or runtime.LockOSThread.
  • Although h2non/filetype is written in pure Go, it doesn't detect a variety of types. Further, surprisingly, its detection is not deterministic. IOW, for the same input file, MIME type detected can be different on each run! This is not recommended for any production use.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL