Skip to content

Go Bindings for libmagic and an idiomatic API for getting a file's MIME type.

License

Notifications You must be signed in to change notification settings

isabella232/go-magic

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-magic

Go library for getting MIME type using libmagic

Installing

go get github.com/vimeo/go-magic/magic

Dependencies

libmagic
URL: http://www.darwinsys.com/file/
Ubuntu: apt-get install libmagic-dev
CentOS: yum install file-devel

Usage

  • Create some custom magic files (e.g. ~/magicfiles)
  • Add the default system magic file dir
    • magic.AddMagicDir(magic.GetDefaultDir())
  • Add the custom magic file dir
    • magic.AddMagicDir("~/magicfiles")
  • Get MIME type with either one of:
    • magic.MimeFromFile(filename)
    • magic.MimeFromBytes(data)

API Documentation

http://godoc.org/github.com/vimeo/go-magic/magic

About

Go Bindings for libmagic and an idiomatic API for getting a file's MIME type.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%