Back to

Package mime

Latest Go to latest

The latest major version is .

Published: Aug 25, 2019 | Licenses: GPL3 , Apache-2.0 | Module:


package mime implements part of the shared-mime-info spec for guessing by extension and partial matching by header


type Database

type Database struct {
	// contains filtered or unexported fields

Database holds the LUTs for glob matching and magic matching

func NewDatabase

func NewDatabase() *Database

NewDatabase Creates a new empty database

func (*Database) GuessExtByMIME

func (d *Database) GuessExtByMIME(mime string) string

GuessExtByMIME attempts to get a file extension (including the dot) by a mime type.

func (*Database) GuessMIMEByHeader

func (d *Database) GuessMIMEByHeader(header []byte) string

GuessMIMEByHeader attemtps to deterimine the MIME type by the file's header. It returns "" on failure

func (*Database) GuessMIMEByName

func (d *Database) GuessMIMEByName(name string) string

GuessMIMEByName guesses a mime type by filename. This is faster than guessing by magic, but very easy to fool returns a empty string on failure

func (*Database) ReadFreeDesktop

func (db *Database) ReadFreeDesktop(database io.Reader) error

ReadFreeDesktop reads into a existing database from a XML document stream describing mime matching

func (*Database) RecommendedLength

func (d *Database) RecommendedLength() int

RecommendedLength returns the length required by GuessMIMEByHeader for all matches

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier