# gabriel-vasile/mimetype

A Go package for media type and file extension detection, based on magic numbers

Repository: https://github.com/gabriel-vasile/mimetype
Canonical: https://ross.abutalabs.com/products/mimetype
Homepage: https://pkg.go.dev/github.com/gabriel-vasile/mimetype#pkg-overview
Language: Go
License: MIT
License Family: permissive
Topics: magic-numbers, sniffing, mime, media-types, detection, mimetype, golang, go
Last push: 2026-08-10T11:25:36+00:00

## Health v2 (maintenance only)
Score: 92/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 97, release rhythm 82, longevity 100
- inputs: {"age_days": 2984, "days_push": 23, "days_rel": 41, "gap_med": 50, "n_releases_24m": 10}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2012, forks 200 (observed 2026-08-28T04:06:05.166478+00:00)

## What it is
A pure-Go library for detecting MIME types and file extensions from file content using magic numbers. It is goroutine-safe, dependency-free, extensible with custom formats, and can differentiate text from binary files.

## Use cases
- detect the mime type of an uploaded file in Go
- validate file uploads by content instead of extension
- get a file extension from raw bytes
- sniff whether a file is text or binary
- detect file type without libmagic or C bindings
- identify document formats like Office files from their signatures

## When to choose
- you need content-based file type detection in a Go program
- you want a dependency-free, concurrency-safe alternative to libmagic
- you need to validate uploads whose declared Content-Type may be wrong
- you need to extend detection with custom file formats

## When to avoid
- metadata is already available from the protocol, e.g. HTTP or SMTP Content-Type headers
- you need detection of formats whose signatures lie far into large files and cannot afford reading more bytes
- you are not working in Go

## Facets
- artifact type: library
- maturity: stable
- function: parser, developer-tools
- domain: files, developer-tools, web-development
- platform: go, cross-platform
- tags: mime-detection, magic-numbers, file-type-sniffing, file-extensions, content-type

## Member repositories
- gabriel-vasile/mimetype (main) score 92

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:05.166478+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:01:02.058560+00:00, confidence not recorded.
  - readme: https://github.com/gabriel-vasile/mimetype (fetched 2026-08-28T04:06:05.166478+00:00, sha 2144f7bd9c87)
  - homepage: https://pkg.go.dev/github.com/gabriel-vasile/mimetype#pkg-overview (fetched 2026-08-29T10:40:56.159483+00:00, sha afcfe79b3879)
  - site_page: https://pkg.go.dev/about (fetched 2026-08-29T10:40:56.166166+00:00, sha 757852027879)
  - site_page: https://pkg.go.dev/github.com/gabriel-vasile/mimetype (fetched 2026-08-29T10:40:56.163665+00:00, sha afcfe79b3879)
  - site_page: https://go.dev/project (fetched 2026-08-29T10:40:56.168270+00:00, sha d5ca00bb378b)
- Data as of 2026-08-30T08:39:29.467469+00:00.
