mime

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mime provides dependency-light magic-byte MIME sniffing and canonicalization for supported image, PDF, and audio media formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canonical

func Canonical(mimeType string) string

Canonical normalizes equivalent MIME spellings (such as audio/wave -> audio/wav).

Types

type Kind

type Kind string

Kind categorizes a detected media MIME type without coupling to AI model profiles.

const (
	KindImage Kind = "image"
	KindPDF   Kind = "pdf"
	KindAudio Kind = "audio"
)

func Detect

func Detect(filename string, data []byte) (string, Kind, bool)

Detect inspects filename and header bytes (magic bytes + extension) to identify supported image, PDF, and audio MIME types. SVG files deliberately return false so callers keep them on the UTF-8 text path.

func KindFor

func KindFor(mimeType string) (Kind, bool)

KindFor maps a supported MIME type to its media kind.

Jump to

Keyboard shortcuts

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