magic

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Overview

Package magic holds the matching functions used to find MIME types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AAC

func AAC(raw []byte, _ uint32) bool

AAC matches an Advanced Audio Coding file.

func AMp4

func AMp4(raw []byte, _ uint32) bool

AMp4 matches an audio MP4 file.

func APK added in v0.17.0

func APK(raw []byte, _ uint32) bool

APK matches an Android Package Archive. The source of signatures is https://github.com/file/file/blob/1778642b8ba3d947a779a36fcd81f8e807220a19/magic/Magdir/archive#L1820-L1887

func AVIF

func AVIF(raw []byte, _ uint32) bool

AVIF matches an AV1 Image File Format still or animated. Wikipedia page seems outdated listing image/avif-sequence for animations. https://github.com/AOMediaCodec/av1-avif/issues/59

func Aiff

func Aiff(raw []byte, limit uint32) bool

Aiff matches Audio Interchange File Format file.

func Amf

func Amf(raw []byte, _ uint32) bool

Amf matches an Additive Manufacturing XML file.

func Amr

func Amr(raw []byte, _ uint32) bool

Amr matches an Adaptive Multi-Rate file.

func Ape

func Ape(raw []byte, _ uint32) bool

Ape matches a Monkey's Audio file.

func Apng

func Apng(raw []byte, _ uint32) bool

Apng matches an Animated Portable Network Graphics file. https://wiki.mozilla.org/APNG_Specification

func Ar

func Ar(raw []byte, _ uint32) bool

Ar matches an ar (Unix) archive file.

func Asf

func Asf(raw []byte, _ uint32) bool

Asf matches an Advanced Systems Format file.

func Atom

func Atom(raw []byte, _ uint32) bool

Atom matches an Atom Syndication Format file.

func Au

func Au(raw []byte, _ uint32) bool

Au matches a Sun Microsystems au file.

func Avi

func Avi(raw []byte, limit uint32) bool

Avi matches an Audio Video Interleaved file.

func Bmp

func Bmp(raw []byte, _ uint32) bool

Bmp matches a bitmap image file.

func Bpg

func Bpg(raw []byte, _ uint32) bool

Bpg matches a Better Portable Graphics file.

func Bz2

func Bz2(raw []byte, _ uint32) bool

Bz2 matches a bzip2 file.

func CBOR

func CBOR(raw []byte, _ uint32) bool

CBOR matches a Concise Binary Object Representation https://cbor.io/

func CHM added in v0.20.0

func CHM(raw []byte, _ uint32) bool

CHM matches a Microsoft Compiled HTML Help file.

func CRX

func CRX(raw []byte, limit uint32) bool

CRX matches a Chrome extension file: a zip archive prepended by a package header.

func CSV added in v0.18.1

func CSV(raw []byte, limit uint32) bool

CSV matches a comma-separated values file.

func Cab

func Cab(raw []byte, _ uint32) bool

Cab matches a Microsoft Cabinet archive file.

func Class

func Class(raw []byte, limit uint32) bool

Class matches a java class file.

func Collada

func Collada(raw []byte, _ uint32) bool

Collada matches a COLLAborative Design Activity file.

func Cpio

func Cpio(raw []byte, _ uint32) bool

Cpio matches a cpio archive file.

func DXF added in v0.20.0

func DXF(raw []byte, _ uint32) bool

DXF matches Drawing Exchange Format AutoCAD file. There does not seem to be a clear specification and the files in the wild differ wildly. https://images.autodesk.com/adsk/files/autocad_2012_pdf_dxf-reference_enu.pdf

I collected these signatures by downloading a few dozen files from http://cd.textfiles.com/amigaenv/DXF/OBJEKTE/ and https://sembiance.com/fileFormatSamples/poly/dxf/ and then xxd -l 16 {} | sort | uniq. These signatures are only for the ASCII version of DXF. There is a binary version too.

func Dbf

func Dbf(raw []byte, limit uint32) bool

Dbf matches a dBase file. https://www.dbase.com/Knowledgebase/INT/db7_file_fmt.htm

func Dcm

func Dcm(raw []byte, limit uint32) bool

Dcm matches a DICOM medical format file.

func Deb

func Deb(raw []byte, _ uint32) bool

Deb matches a Debian package file.

func DjVu

func DjVu(raw []byte, _ uint32) bool

DjVu matches a DjVu file.

func Docx

func Docx(raw []byte, limit uint32) bool

Docx matches a Microsoft Word 2007 file.

func Dwg

func Dwg(raw []byte, _ uint32) bool

Dwg matches a CAD drawing file.

func Elf

func Elf(raw []byte, _ uint32) bool

Elf matches an Executable and Linkable Format file.

func ElfDump

func ElfDump(raw []byte, limit uint32) bool

ElfDump matches a core dump file.

func ElfExe

func ElfExe(raw []byte, limit uint32) bool

ElfExe matches an executable file.

func ElfLib

func ElfLib(raw []byte, limit uint32) bool

ElfLib matches a shared library file.

func ElfObj

func ElfObj(raw []byte, limit uint32) bool

ElfObj matches an object file.

func Eot

func Eot(raw []byte, limit uint32) bool

Eot matches an Embedded OpenType font file.

func Epub

func Epub(raw []byte, _ uint32) bool

Epub matches an EPUB file.

func Exe

func Exe(raw []byte, _ uint32) bool

Exe matches a Windows/DOS executable file.

func Fdf

func Fdf(raw []byte, _ uint32) bool

Fdf matches a Forms Data Format file.

func Fits

func Fits(raw []byte, _ uint32) bool

Fits matches an Flexible Image Transport System file.

func Flac

func Flac(raw []byte, _ uint32) bool

Flac matches a Free Lossless Audio Codec file.

func Flv

func Flv(raw []byte, _ uint32) bool

Flv matches a Flash video file.

func GLB added in v0.17.2

func GLB(raw []byte, _ uint32) bool

GLB matches a glTF model format file. GLB is the binary file format representation of 3D models saved in the GL transmission Format (glTF). GLB uses little endian and its header structure is as follows:

<-- 12-byte header                             -->
| magic            | version          | length   |
| (uint32)         | (uint32)         | (uint32) |
| \x67\x6C\x54\x46 | \x01\x00\x00\x00 | ...      |
| g   l   T   F    | 1                | ...      |

Visit glTF specification and IANA glTF entry for more details.

func GLTF added in v0.17.2

func GLTF(raw []byte, limit uint32) bool

GLTF matches a GL Transmission Format (JSON) file. Visit glTF specification and IANA glTF entry for more details.

func Gbr

func Gbr(raw []byte, _ uint32) bool

Gbr matches GIMP brush data.

func GeoJSON

func GeoJSON(raw []byte, limit uint32) bool

GeoJSON matches a RFC 7946 GeoJSON file.

GeoJSON detection implies searching for key:value pairs like: `"type": "Feature"` in the input.

func Gif

func Gif(raw []byte, _ uint32) bool

Gif matches a Graphics Interchange Format file.

func Gml

func Gml(raw []byte, _ uint32) bool

Gml matches a Geography Markup Language file.

func Gpx

func Gpx(raw []byte, _ uint32) bool

Gpx matches a GPS Exchange Format file.

func Gzip

func Gzip(raw []byte, _ uint32) bool

Gzip matches gzip files based on http://www.zlib.org/rfc-gzip.html#header-trailer.

func HAR

func HAR(raw []byte, limit uint32) bool

HAR matches a HAR Spec file. Spec: http://www.softwareishard.com/blog/har-12-spec/

func HTML

func HTML(raw []byte, _ uint32) bool

HTML matches a Hypertext Markup Language file.

func Heic

func Heic(raw []byte, _ uint32) bool

Heic matches a High Efficiency Image Coding (HEIC) file.

func HeicSequence

func HeicSequence(raw []byte, _ uint32) bool

HeicSequence matches a High Efficiency Image Coding (HEIC) file sequence.

func Heif

func Heif(raw []byte, _ uint32) bool

Heif matches a High Efficiency Image File Format (HEIF) file.

func HeifSequence

func HeifSequence(raw []byte, _ uint32) bool

HeifSequence matches a High Efficiency Image File Format (HEIF) file sequence.

func ICalendar

func ICalendar(raw []byte, _ uint32) bool

ICalendar matches a iCalendar file.

func Icns

func Icns(raw []byte, _ uint32) bool

Icns matches an ICNS (Apple Icon Image format) file.

func Ico

func Ico(raw []byte, _ uint32) bool

Ico matches an ICO file.

func InstallShieldCab

func InstallShieldCab(raw []byte, _ uint32) bool

InstallShieldCab matches an InstallShield Cabinet archive file.

func JSON

func JSON(raw []byte, limit uint32) bool

JSON matches a JavaScript Object Notation file.

func Jar

func Jar(raw []byte, limit uint32) bool

Jar matches a Java archive file. There are two types of Jar files: 1. the ones that can be opened with jexec and have 0xCAFE optional flag https://stackoverflow.com/tags/executable-jar/info 2. regular jars, same as above, just without the executable flag https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262278#c0 There is an argument to only check for manifest, since it's the common nominator for both executable and non-executable versions. But the traversing zip entries is unreliable because it does linear search for signatures (instead of relying on offsets told by the file.)

func Jp2

func Jp2(raw []byte, _ uint32) bool

Jp2 matches a JPEG 2000 Image file (ISO 15444-1).

func Jpg

func Jpg(raw []byte, _ uint32) bool

Jpg matches a Joint Photographic Experts Group file.

func Jpm

func Jpm(raw []byte, _ uint32) bool

Jpm matches a JPEG 2000 Image file (ISO 15444-6).

func Jpx

func Jpx(raw []byte, _ uint32) bool

Jpx matches a JPEG 2000 Image file (ISO 15444-2).

func Js

func Js(raw []byte, _ uint32) bool

Js matches a Javascript file.

func Jxl

func Jxl(raw []byte, _ uint32) bool

Jxl matches JPEG XL image file.

func Jxr

func Jxr(raw []byte, _ uint32) bool

Jxr matches Microsoft HD JXR photo file.

func Jxs

func Jxs(raw []byte, _ uint32) bool

Jxs matches a JPEG XS coded image file (ISO/IEC 21122-3).

func KMZ added in v0.20.0

func KMZ(raw []byte, _ uint32) bool

KMZ matches a zipped KML file, which is "doc.kml" by convention.

func Kml

func Kml(raw []byte, _ uint32) bool

Kml matches a Keyhole Markup Language file.

func Lit

func Lit(raw []byte, _ uint32) bool

Lit matches a Microsoft Lit file.

func Lnk

func Lnk(raw []byte, _ uint32) bool

Lnk matches Microsoft lnk binary format.

func Lotus123 added in v0.20.0

func Lotus123(raw []byte, _ uint32) bool

Lotus123 matches a Lotus 1-2-3 spreadsheet document.

func Lua

func Lua(raw []byte, _ uint32) bool

Lua matches a Lua programming language file.

func Lzip

func Lzip(raw []byte, _ uint32) bool

Lzip matches an Lzip compressed file.

func M3u

func M3u(raw []byte, _ uint32) bool

M3u matches a Playlist file.

func M4a

func M4a(raw []byte, _ uint32) bool

M4a matches an audio M4A file.

func M4v

func M4v(raw []byte, _ uint32) bool

M4v matches an Appl4 M4V video file.

func MachO

func MachO(raw []byte, limit uint32) bool

MachO matches Mach-O binaries format.

func Marc

func Marc(raw []byte, limit uint32) bool

Marc matches a MARC21 (MAchine-Readable Cataloging) file.

func Midi

func Midi(raw []byte, _ uint32) bool

Midi matches a Musical Instrument Digital Interface file.

func Mj2

func Mj2(raw []byte, _ uint32) bool

Mj2 matches a Motion JPEG 2000 file: https://en.wikipedia.org/wiki/Motion_JPEG_2000.

func Mkv

func Mkv(raw []byte, limit uint32) bool

Mkv matches a mkv file.

func Mobi

func Mobi(raw []byte, _ uint32) bool

Mobi matches a Mobi file.

func Mp3

func Mp3(raw []byte, limit uint32) bool

Mp3 matches an mp3 file.

func Mp4

func Mp4(raw []byte, _ uint32) bool

Mp4 detects an .mp4 file. Mp4 detections only does a basic ftyp check. Mp4 has many registered and unregistered code points so it's hard to keep track of all. Detection will default on video/mp4 for all ftyp files. ISO_IEC_14496-12 is the specification for the iso container.

func Mpeg

func Mpeg(raw []byte, limit uint32) bool

Mpeg matches a Moving Picture Experts Group file.

func Mqv

func Mqv(raw []byte, _ uint32) bool

Mqv matches a Sony / Mobile QuickTime file.

func MsAccessAce

func MsAccessAce(raw []byte, _ uint32) bool

MsAccessAce matches Microsoft Access dababase file.

func MsAccessMdb

func MsAccessMdb(raw []byte, _ uint32) bool

MsAccessMdb matches legacy Microsoft Access database file (JET, 2003 and earlier).

func Msg

func Msg(raw []byte, limit uint32) bool

Msg matches a Microsoft Outlook email file.

func Msi

func Msi(raw []byte, limit uint32) bool

Msi matches a Microsoft Windows Installer file. http://fileformats.archiveteam.org/wiki/Microsoft_Compound_File

func MusePack

func MusePack(raw []byte, _ uint32) bool

MusePack matches a Musepack file.

func NdJSON

func NdJSON(raw []byte, limit uint32) bool

NdJSON matches a Newline delimited JSON file. All complete lines from raw must be valid JSON documents meaning they contain one of the valid JSON data types.

func Nes

func Nes(raw []byte, _ uint32) bool

Nes matches a Nintendo Entertainment system ROM file.

func NetPAM added in v0.20.0

func NetPAM(raw []byte, _ uint32) bool

NetPAM matches a Netpbm Portable Arbitrary Map file.

See: https://en.wikipedia.org/wiki/Netpbm

func NetPBM added in v0.20.0

func NetPBM(raw []byte, _ uint32) bool

NetPBM matches a Netpbm Portable BitMap ASCII/Binary file.

See: https://en.wikipedia.org/wiki/Netpbm

func NetPGM added in v0.20.0

func NetPGM(raw []byte, _ uint32) bool

NetPGM matches a Netpbm Portable GrayMap ASCII/Binary file.

See: https://en.wikipedia.org/wiki/Netpbm

func NetPPM added in v0.20.0

func NetPPM(raw []byte, _ uint32) bool

NetPPM matches a Netpbm Portable PixMap ASCII/Binary file.

See: https://en.wikipedia.org/wiki/Netpbm

func Odc

func Odc(raw []byte, _ uint32) bool

Odc matches an OpenDocument Chart file.

func Odf

func Odf(raw []byte, _ uint32) bool

Odf matches an OpenDocument Formula file.

func Odg

func Odg(raw []byte, _ uint32) bool

Odg matches an OpenDocument Drawing file.

func Odp

func Odp(raw []byte, _ uint32) bool

Odp matches an OpenDocument Presentation file.

func Ods

func Ods(raw []byte, _ uint32) bool

Ods matches an OpenDocument Spreadsheet file.

func Odt

func Odt(raw []byte, _ uint32) bool

Odt matches an OpenDocument Text file.

func Ogg

func Ogg(raw []byte, limit uint32) bool

Ogg matches an Ogg file.

func OggAudio

func OggAudio(raw []byte, limit uint32) bool

OggAudio matches an audio ogg file.

func OggVideo

func OggVideo(raw []byte, limit uint32) bool

OggVideo matches a video ogg file.

func Ole

func Ole(raw []byte, limit uint32) bool

Ole matches an Open Linking and Embedding file.

https://en.wikipedia.org/wiki/Object_Linking_and_Embedding

func One added in v0.20.0

func One(raw []byte, limit uint32) bool

One matches a Microsoft OneNote file.

func Otf

func Otf(raw []byte, _ uint32) bool

Otf matches an OpenType font file.

func Otg

func Otg(raw []byte, _ uint32) bool

Otg matches an OpenDocument Drawing Template file.

func Otp

func Otp(raw []byte, _ uint32) bool

Otp matches an OpenDocument Presentation Template file.

func Ots

func Ots(raw []byte, _ uint32) bool

Ots matches an OpenDocument Spreadsheet Template file.

func Ott

func Ott(raw []byte, _ uint32) bool

Ott matches an OpenDocument Text Template file.

func Owl2

func Owl2(raw []byte, _ uint32) bool

Owl2 matches an Owl ontology file.

func P7s

func P7s(raw []byte, _ uint32) bool

P7s matches an .p7s signature File (PEM, Base64).

func PDF added in v0.18.2

func PDF(raw []byte, _ uint32) bool

PDF matches a Portable Document Format file. The %PDF- header should be the first thing inside the file but many implementations don't follow the rule. The PDF spec at Appendix H says the signature can be prepended by anything. https://bugs.astron.com/view.php?id=446

func Par1

func Par1(raw []byte, _ uint32) bool

PAR1 matches a parquet file.

func Pat

func Pat(raw []byte, _ uint32) bool

Pat matches GIMP pattern data.

func Pdf

func Pdf(raw []byte, _ uint32) bool

Pdf matches a Portable Document Format file. https://github.com/file/file/blob/11010cc805546a3e35597e67e1129a481aed40e8/magic/Magdir/pdf

func Perl

func Perl(raw []byte, _ uint32) bool

Perl matches a Perl programming language file.

func Php added in v0.20.0

func Php(raw []byte, limit uint32) bool

Php matches a PHP: Hypertext Preprocessor file.

func Png

func Png(raw []byte, _ uint32) bool

Png matches a Portable Network Graphics file. https://www.w3.org/TR/PNG/

func Ppt

func Ppt(raw []byte, limit uint32) bool

Ppt matches a Microsoft PowerPoint 97-2003 file or a PowerPoint 95 presentation.

func Pptx

func Pptx(raw []byte, limit uint32) bool

Pptx matches a Microsoft PowerPoint 2007 file.

func Ps

func Ps(raw []byte, _ uint32) bool

Ps matches a PostScript file.

func Psd

func Psd(raw []byte, _ uint32) bool

Psd matches a Photoshop Document file.

func Pub

func Pub(raw []byte, limit uint32) bool

Pub matches a Microsoft Publisher file.

func Python

func Python(raw []byte, _ uint32) bool

Python matches a Python programming language file.

func Qcp

func Qcp(raw []byte, limit uint32) bool

Qcp matches a Qualcomm Pure Voice file.

func RAR

func RAR(raw []byte, _ uint32) bool

RAR matches a RAR archive file.

func RPM

func RPM(raw []byte, _ uint32) bool

RPM matches an RPM or Delta RPM package file.

func Rmvb

func Rmvb(raw []byte, _ uint32) bool

Rmvb matches a RealMedia Variable Bitrate file.

func Rss

func Rss(raw []byte, _ uint32) bool

Rss matches a Rich Site Summary file.

func Rtf

func Rtf(raw []byte, _ uint32) bool

Rtf matches a Rich Text Format file.

func Ruby added in v0.20.0

func Ruby(raw []byte, _ uint32) bool

Ruby matches a Ruby programming language file.

func SWF

func SWF(raw []byte, _ uint32) bool

SWF matches an Adobe Flash swf file.

func SevenZ

func SevenZ(raw []byte, _ uint32) bool

SevenZ matches a 7z archive.

func Shell added in v0.20.0

func Shell(raw []byte, _ uint32) bool

Shell matches a shell script file.

func Shp

func Shp(raw []byte, limit uint32) bool

Shp matches a shape format file. https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf

func Shx

func Shx(raw []byte, limit uint32) bool

Shx matches a shape index format file. https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf

func Sqlite

func Sqlite(raw []byte, _ uint32) bool

Sqlite matches an SQLite database file.

func Srt

func Srt(raw []byte, _ uint32) bool

Srt matches a SubRip file.

func Svg

func Svg(raw []byte, limit uint32) bool

Svg matches a SVG file.

func Sxc

func Sxc(raw []byte, _ uint32) bool

Sxc matches an OpenOffice Spreadsheet file.

func TSV added in v0.18.1

func TSV(raw []byte, limit uint32) bool

TSV matches a tab-separated values file.

func Tar

func Tar(raw []byte, _ uint32) bool

Tar matches a (t)ape (ar)chive file. Tar files are divided into 512 bytes records. First record contains a 257 bytes header padded with NUL.

func Tcl

func Tcl(raw []byte, _ uint32) bool

Tcl matches a Tcl programming language file.

func Tcx

func Tcx(raw []byte, _ uint32) bool

Tcx matches a Training Center XML file.

func Text

func Text(raw []byte, _ uint32) bool

Text matches a plain text file.

TODO: This function does not parse BOM-less UTF16 and UTF32 files. Not really sure it should. Linux file utility also requires a BOM for UTF16 and UTF32.

func ThreeG2

func ThreeG2(raw []byte, _ uint32) bool

ThreeG2 matches a 3GPP2 file.

func ThreeGP

func ThreeGP(raw []byte, _ uint32) bool

ThreeGP matches a 3GPP file.

func Threemf

func Threemf(raw []byte, _ uint32) bool

Threemf matches a 3D Manufacturing Format file.

func Tiff

func Tiff(raw []byte, _ uint32) bool

Tiff matches a Tagged Image File Format file.

func Torrent

func Torrent(raw []byte, _ uint32) bool

Torrent has bencoded text in the beginning.

func Ttc

func Ttc(raw []byte, limit uint32) bool

Ttc matches a TrueType Collection font file.

func Ttf

func Ttf(raw []byte, limit uint32) bool

Ttf matches a TrueType font file.

func TzIf

func TzIf(raw []byte, limit uint32) bool

TzIf matches a Time Zone Information Format (TZif) file. See more: https://tools.ietf.org/id/draft-murchison-tzdist-tzif-00.html#rfc.section.3 Its header structure is shown below:

+---------------+---+
|  magic    (4) | <-+-- version (1)
+---------------+---+---------------------------------------+
|           [unused - reserved for future use] (15)         |
+---------------+---------------+---------------+-----------+
|  isutccnt (4) |  isstdcnt (4) |  leapcnt  (4) |
+---------------+---------------+---------------+
|  timecnt  (4) |  typecnt  (4) |  charcnt  (4) |

func VCard

func VCard(raw []byte, _ uint32) bool

VCard matches a Virtual Contact File.

func Visio added in v0.20.0

func Visio(raw []byte, limit uint32) bool

Visio matches a Microsoft Visio 2013+ file.

func Voc

func Voc(raw []byte, _ uint32) bool

Voc matches a Creative Voice file.

func Vtt

func Vtt(raw []byte, limit uint32) bool

Vtt matches a Web Video Text Tracks (WebVTT) file. See https://www.iana.org/assignments/media-types/text/vtt.

func WPD added in v0.20.0

func WPD(raw []byte, _ uint32) bool

WPD matches a WordPerfect document.

func Warc

func Warc(raw []byte, _ uint32) bool

Warc matches a Web ARChive file.

func Wasm

func Wasm(raw []byte, _ uint32) bool

Wasm matches a web assembly File Format file.

func Wav

func Wav(raw []byte, limit uint32) bool

Wav matches a Waveform Audio File Format file.

func WebM

func WebM(raw []byte, limit uint32) bool

WebM matches a WebM file.

func Webp

func Webp(raw []byte, _ uint32) bool

Webp matches a WebP file.

func Woff

func Woff(raw []byte, _ uint32) bool

Woff matches a Web Open Font Format file.

func Woff2

func Woff2(raw []byte, _ uint32) bool

Woff2 matches a Web Open Font Format version 2 file.

func X3d

func X3d(raw []byte, _ uint32) bool

X3d matches an Extensible 3D Graphics file.

func XHTML added in v0.20.0

func XHTML(raw []byte, limit uint32) bool

XHTML matches an XHTML file. This check depends on the XML check to have passed.

func XML

func XML(raw []byte, _ uint32) bool

XML matches an Extensible Markup Language file.

func Xar

func Xar(raw []byte, _ uint32) bool

Xar matches an eXtensible ARchive format file.

func Xcf

func Xcf(raw []byte, _ uint32) bool

Xcf matches GIMP image data.

func Xfdf

func Xfdf(raw []byte, _ uint32) bool

Xfdf matches a XML Forms Data Format file.

func Xliff

func Xliff(raw []byte, _ uint32) bool

Xliff matches a XML Localization Interchange File Format file.

func Xls

func Xls(raw []byte, limit uint32) bool

Xls matches a Microsoft Excel 97-2003 file.

func Xlsx

func Xlsx(raw []byte, limit uint32) bool

Xlsx matches a Microsoft Excel 2007 file.

func Xpm

func Xpm(raw []byte, _ uint32) bool

Xpm matches X PixMap image data.

func Xz

func Xz(raw []byte, _ uint32) bool

Xz matches an xz compressed stream based on https://tukaani.org/xz/xz-file-format.txt.

func Zip

func Zip(raw []byte, limit uint32) bool

Zip matches a zip archive.

func Zstd

func Zstd(raw []byte, limit uint32) bool

Zstd matches a Zstandard archive file. https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md

Types

type Detector

type Detector func(raw []byte, limit uint32) bool

Detector receiveѕ the raw data of a file and returns whether the data meets any conditions. The limit parameter is an upper limit to the number of bytes received and is used to tell if the byte slice represents the whole file or is just the header of a file: len(raw) < limit or len(raw)>limit.

Jump to

Keyboard shortcuts

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