mimedb

package module
v1.52.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 1 Imported by: 1

README

MIME DB

This Go package uses generators to convert this database into additions to the stdlib mime package.

Since all the work is done at compile time, the MIME types end up embedded in the binary, loading them on startup is fast, and you still get sensible results when /etc/mime.types is unavailable on your platform!

This work is somewhat inspired by mime-ext-go, which lacks the automatic generation (and so easy update) to be found in this package.

The version of the mime-db package used is tracked in the VERSION file, and updates will be given a corresponding tag.

Contributing

See the contributing guide

How to update

Update the version number in VERSION to the latest version available in jshttp/mimedb. Then run:

go run ./cmd/generate

# outputs generated_mime_types.go
Failing tests

If the tests are failing with a message like:

Mime Type 'application/toml' already registred for extension 'toml' without loading the database!

The latest version of the OS might have caught up with the MIME database which makes the test case outdated. To find a MIME type that exist in mimedb but doesn't exist in OS, you can run go run ./cmd/list/main.go, which lists the mimedb types and extensions.

How to update go

  1. Update the go version in go.mod
  2. Update the GO_VERSION matrix in .gitlab/ci/test.yml

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MimeTypeToExts = map[string][]string{}/* 965 elements not displayed */

)

Functions

func LoadTypes

func LoadTypes() error

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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