utilgo.mau.fi/util/exmime Index | Files

package exmime

import "go.mau.fi/util/exmime"

Index

Variables

var MimeExtensionSanityOverrides = map[string]string{
	"image/png":  ".png",
	"image/webp": ".webp",
	"image/jpeg": ".jpg",
	"image/tiff": ".tiff",
	"image/heif": ".heic",
	"image/heic": ".heic",

	"audio/mpeg":  ".mp3",
	"audio/ogg":   ".ogg",
	"audio/webm":  ".webm",
	"audio/x-caf": ".caf",
	"audio/mp4":   ".m4a",
	"video/mp4":   ".mp4",
	"video/mpeg":  ".mpeg",
	"video/webm":  ".webm",

	"text/plain": ".txt",
	"text/html":  ".html",

	"application/xml": ".xml",
}

MimeExtensionSanityOverrides includes extensions for various common mimetypes.

This is necessary because sometimes the OS mimetype database and Go interact in weird ways, which causes very obscure extensions to be first in the array for common mimetypes (e.g. image/jpeg -> .jpe, text/plain -> ,v).

Functions

func ExtensionFromMimetype

func ExtensionFromMimetype(mimetype string) string

Source Files

mimetypes.go

Version
v0.8.6 (latest)
Published
Mar 16, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
1 week ago

Tools for package owners.