filetype: Index | Files | Directories

package matchers

import ""


Package Files

application.go archive.go audio.go document.go font.go image.go matchers.go video.go


const (
    TYPE_DOC docType = iota


var (
    TypeWasm = newType("wasm", "application/wasm")
    TypeDex  = newType("dex", "application/")
    TypeDey  = newType("dey", "application/")
var (
    TypeEpub   = newType("epub", "application/epub+zip")
    TypeZip    = newType("zip", "application/zip")
    TypeTar    = newType("tar", "application/x-tar")
    TypeRar    = newType("rar", "application/vnd.rar")
    TypeGz     = newType("gz", "application/gzip")
    TypeBz2    = newType("bz2", "application/x-bzip2")
    Type7z     = newType("7z", "application/x-7z-compressed")
    TypeXz     = newType("xz", "application/x-xz")
    TypePdf    = newType("pdf", "application/pdf")
    TypeExe    = newType("exe", "application/")
    TypeSwf    = newType("swf", "application/x-shockwave-flash")
    TypeRtf    = newType("rtf", "application/rtf")
    TypeEot    = newType("eot", "application/octet-stream")
    TypePs     = newType("ps", "application/postscript")
    TypeSqlite = newType("sqlite", "application/vnd.sqlite3")
    TypeNes    = newType("nes", "application/x-nintendo-nes-rom")
    TypeCrx    = newType("crx", "application/x-google-chrome-extension")
    TypeCab    = newType("cab", "application/")
    TypeDeb    = newType("deb", "application/vnd.debian.binary-package")
    TypeAr     = newType("ar", "application/x-unix-archive")
    TypeZ      = newType("Z", "application/x-compress")
    TypeLz     = newType("lz", "application/x-lzip")
    TypeRpm    = newType("rpm", "application/x-rpm")
    TypeElf    = newType("elf", "application/x-executable")
    TypeDcm    = newType("dcm", "application/dicom")
    TypeIso    = newType("iso", "application/x-iso9660-image")
    TypeMachO  = newType("macho", "application/x-mach-binary") // Mach-O binaries have no common extension.
var (
    TypeMidi = newType("mid", "audio/midi")
    TypeMp3  = newType("mp3", "audio/mpeg")
    TypeM4a  = newType("m4a", "audio/m4a")
    TypeOgg  = newType("ogg", "audio/ogg")
    TypeFlac = newType("flac", "audio/x-flac")
    TypeWav  = newType("wav", "audio/x-wav")
    TypeAmr  = newType("amr", "audio/amr")
    TypeAac  = newType("aac", "audio/aac")
var (
    TypeDoc  = newType("doc", "application/msword")
    TypeDocx = newType("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
    TypeXls  = newType("xls", "application/")
    TypeXlsx = newType("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
    TypePpt  = newType("ppt", "application/")
    TypePptx = newType("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation")
var (
    TypeWoff  = newType("woff", "application/font-woff")
    TypeWoff2 = newType("woff2", "application/font-woff")
    TypeTtf   = newType("ttf", "application/font-sfnt")
    TypeOtf   = newType("otf", "application/font-sfnt")
var (
    TypeJpeg     = newType("jpg", "image/jpeg")
    TypeJpeg2000 = newType("jp2", "image/jp2")
    TypePng      = newType("png", "image/png")
    TypeGif      = newType("gif", "image/gif")
    TypeWebp     = newType("webp", "image/webp")
    TypeCR2      = newType("cr2", "image/x-canon-cr2")
    TypeTiff     = newType("tif", "image/tiff")
    TypeBmp      = newType("bmp", "image/bmp")
    TypeJxr      = newType("jxr", "image/")
    TypePsd      = newType("psd", "image/vnd.adobe.photoshop")
    TypeIco      = newType("ico", "image/")
    TypeHeif     = newType("heif", "image/heif")
    TypeDwg      = newType("dwg", "image/vnd.dwg")
var (
    TypeMp4  = newType("mp4", "video/mp4")
    TypeM4v  = newType("m4v", "video/x-m4v")
    TypeMkv  = newType("mkv", "video/x-matroska")
    TypeWebm = newType("webm", "video/webm")
    TypeMov  = newType("mov", "video/quicktime")
    TypeAvi  = newType("avi", "video/x-msvideo")
    TypeWmv  = newType("wmv", "video/x-ms-wmv")
    TypeMpeg = newType("mpg", "video/mpeg")
    TypeFlv  = newType("flv", "video/x-flv")
    Type3gp  = newType("3gp", "video/3gpp")
var Application = Map{
    TypeWasm: Wasm,
    TypeDex:  Dex,
    TypeDey:  Dey,
var Archive = Map{
    TypeEpub:   Epub,
    TypeZip:    Zip,
    TypeTar:    Tar,
    TypeRar:    Rar,
    TypeGz:     Gz,
    TypeBz2:    Bz2,
    Type7z:     SevenZ,
    TypeXz:     Xz,
    TypePdf:    Pdf,
    TypeExe:    Exe,
    TypeSwf:    Swf,
    TypeRtf:    Rtf,
    TypeEot:    Eot,
    TypePs:     Ps,
    TypeSqlite: Sqlite,
    TypeNes:    Nes,
    TypeCrx:    Crx,
    TypeCab:    Cab,
    TypeDeb:    Deb,
    TypeAr:     Ar,
    TypeZ:      Z,
    TypeLz:     Lz,
    TypeRpm:    Rpm,
    TypeElf:    Elf,
    TypeDcm:    Dcm,
    TypeIso:    Iso,
    TypeMachO:  MachO,
var Audio = Map{
    TypeMidi: Midi,
    TypeMp3:  Mp3,
    TypeM4a:  M4a,
    TypeOgg:  Ogg,
    TypeFlac: Flac,
    TypeWav:  Wav,
    TypeAmr:  Amr,
    TypeAac:  Aac,
var Document = Map{
    TypeDoc:  Doc,
    TypeDocx: Docx,
    TypeXls:  Xls,
    TypeXlsx: Xlsx,
    TypePpt:  Ppt,
    TypePptx: Pptx,
var Font = Map{
    TypeWoff:  Woff,
    TypeWoff2: Woff2,
    TypeTtf:   Ttf,
    TypeOtf:   Otf,
var Image = Map{
    TypeJpeg:     Jpeg,
    TypeJpeg2000: Jpeg2000,
    TypePng:      Png,
    TypeGif:      Gif,
    TypeWebp:     Webp,
    TypeCR2:      CR2,
    TypeTiff:     Tiff,
    TypeBmp:      Bmp,
    TypeJxr:      Jxr,
    TypePsd:      Psd,
    TypeIco:      Ico,
    TypeHeif:     Heif,
    TypeDwg:      Dwg,
var MatcherKeys []types.Type
var Matchers = make(map[types.Type]TypeMatcher)

Store registered file type matchers

var Video = Map{
    TypeMp4:  Mp4,
    TypeM4v:  M4v,
    TypeMkv:  Mkv,
    TypeWebm: Webm,
    TypeMov:  Mov,
    TypeAvi:  Avi,
    TypeWmv:  Wmv,
    TypeMpeg: Mpeg,
    TypeFlv:  Flv,
    Type3gp:  Match3gp,

func Aac Uses

func Aac(buf []byte) bool

func Amr Uses

func Amr(buf []byte) bool

func Ar Uses

func Ar(buf []byte) bool

func Avi Uses

func Avi(buf []byte) bool

func Bmp Uses

func Bmp(buf []byte) bool

func Bz2 Uses

func Bz2(buf []byte) bool

func CR2 Uses

func CR2(buf []byte) bool

func Cab Uses

func Cab(buf []byte) bool

func Crx Uses

func Crx(buf []byte) bool

func Dcm Uses

func Dcm(buf []byte) bool

func Deb Uses

func Deb(buf []byte) bool

func Dex Uses

func Dex(buf []byte) bool

Dex detects dalvik executable(DEX)

func Dey Uses

func Dey(buf []byte) bool

Dey Optimized Dalvik Executable(ODEX)

func Doc Uses

func Doc(buf []byte) bool


func Docx Uses

func Docx(buf []byte) bool

func Dwg Uses

func Dwg(buf []byte) bool

func Elf Uses

func Elf(buf []byte) bool

func Eot Uses

func Eot(buf []byte) bool

func Epub Uses

func Epub(buf []byte) bool

func Exe Uses

func Exe(buf []byte) bool

func Flac Uses

func Flac(buf []byte) bool

func Flv Uses

func Flv(buf []byte) bool

func Gif Uses

func Gif(buf []byte) bool

func Gz Uses

func Gz(buf []byte) bool

func Heif Uses

func Heif(buf []byte) bool

func Ico Uses

func Ico(buf []byte) bool

func Iso Uses

func Iso(buf []byte) bool

func Jpeg Uses

func Jpeg(buf []byte) bool

func Jpeg2000 Uses

func Jpeg2000(buf []byte) bool

func Jxr Uses

func Jxr(buf []byte) bool

func Lz Uses

func Lz(buf []byte) bool

func M4a Uses

func M4a(buf []byte) bool

func M4v Uses

func M4v(buf []byte) bool

func MachO Uses

func MachO(buf []byte) bool

func Match3gp Uses

func Match3gp(buf []byte) bool

func Midi Uses

func Midi(buf []byte) bool

func Mkv Uses

func Mkv(buf []byte) bool

func Mov Uses

func Mov(buf []byte) bool

func Mp3 Uses

func Mp3(buf []byte) bool

func Mp4 Uses

func Mp4(buf []byte) bool

func Mpeg Uses

func Mpeg(buf []byte) bool

func Nes Uses

func Nes(buf []byte) bool

func Ogg Uses

func Ogg(buf []byte) bool

func Otf Uses

func Otf(buf []byte) bool

func Pdf Uses

func Pdf(buf []byte) bool

func Png Uses

func Png(buf []byte) bool

func Ppt Uses

func Ppt(buf []byte) bool

func Pptx Uses

func Pptx(buf []byte) bool

func Ps Uses

func Ps(buf []byte) bool

func Psd Uses

func Psd(buf []byte) bool

func Rar Uses

func Rar(buf []byte) bool

func Rpm Uses

func Rpm(buf []byte) bool

func Rtf Uses

func Rtf(buf []byte) bool

func SevenZ Uses

func SevenZ(buf []byte) bool

func Sqlite Uses

func Sqlite(buf []byte) bool

func Swf Uses

func Swf(buf []byte) bool

func Tar Uses

func Tar(buf []byte) bool

func Tiff Uses

func Tiff(buf []byte) bool

func Ttf Uses

func Ttf(buf []byte) bool

func Wasm Uses

func Wasm(buf []byte) bool

Wasm detects a Web Assembly 1.0 filetype.

func Wav Uses

func Wav(buf []byte) bool

func Webm Uses

func Webm(buf []byte) bool

func Webp Uses

func Webp(buf []byte) bool

func Wmv Uses

func Wmv(buf []byte) bool

func Woff Uses

func Woff(buf []byte) bool

func Woff2 Uses

func Woff2(buf []byte) bool

func Xls Uses

func Xls(buf []byte) bool

func Xlsx Uses

func Xlsx(buf []byte) bool

func Xz Uses

func Xz(buf []byte) bool

func Z Uses

func Z(buf []byte) bool

func Zip Uses

func Zip(buf []byte) bool

type Map Uses

type Map map[types.Type]Matcher

Type interface to store pairs of type with its matcher function

type Matcher Uses

type Matcher func([]byte) bool

Matcher function interface as type alias

type TypeMatcher Uses

type TypeMatcher func([]byte) types.Type

Type specific matcher function interface

func NewMatcher Uses

func NewMatcher(kind types.Type, fn Matcher) TypeMatcher

Create and register a new type matcher function



Package matchers imports 4 packages (graph) and is imported by 19 packages. Updated 2020-12-01. Refresh now. Tools for package owners.