Package ext2media provides tools inferring what media-type (MIME type) is associated with a file-extension, for the Go programming language.
Find a file
2025-09-05 15:20:21 -07:00
default.go codeberg & ext2mime -> ext2media 2025-09-05 15:09:42 -07:00
errors.go codeberg & ext2mime -> ext2media 2025-09-05 15:09:42 -07:00
get.go media-type 2025-09-05 15:20:21 -07:00
go.mod codeberg & ext2mime -> ext2media 2025-09-05 15:09:42 -07:00
init.go .activity -> application/activity+json 2025-09-05 15:12:19 -07:00
LICENSE initial commit 2024-03-12 22:32:22 -07:00
mapping.go media-type 2025-09-05 15:18:19 -07:00
README.md media-type 2025-09-05 15:18:19 -07:00
set.go media-type 2025-09-05 15:18:19 -07:00

go-ext2media

Package ext2media provides tools inferring what media-type (MIME type) is associated with a file-extension, for the Go programming language.

For example:

  • .css -> text/css
  • .epub -> application/epub+zip,
  • .html -> text/html,
  • .jpeg -> image/jpeg
  • .js -> text/javascript,
  • .json -> application/json,
  • .md -> text/markdown,
  • .png -> image/png
  • .qoi -> image/qoi
  • etc etc etc.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/codeberg.org/reiver/go-ext2media

GoDoc

Example

Here is a simple example:

import "codeberg.org/reiver/go-ext2media"

// ...

fileExtension := path.Ext(filename)

mediaType := ext2media.Get(fileExtension)

You can also add you own file-extension to MIME-type mapping with:

func init() {
	const fileExtension string = ".abc"
	const mediaType string = "application/abc"

	ext2media.Set(fileExtension, mediaType)
}

Import

To import package ext2media use import code like the follownig:

import "codeberg.org/reiver/go-ext2media"

Installation

To install package ext2media do the following:

GOPROXY=direct go get https://codeberg.org/reiver/go-ext2media

Author

Package ext2media was written by Charles Iliya Krempeaux