Standard library / mime

mime.ExtensionsByType()

Look up known extensions for a media type. The installed system database can affect results; use a synthetic registration for reproducibility. Expected stdout: '[.bytemind36]\n'.

Formal Syntax & Structure

go syntaxgo
func ExtensionsByType(typ string) ([]string, error)

Parameters & Attributes

NameTypeDescription
typstringMedia type to associate or look up.

Return Value

([]string, error)

Known extensions (possibly nil) and error.

Working Example

Example Snippetgo
package main
import (  "fmt"  "mime")
func main() {  check(mime.AddExtensionType(".bytemind36", "application/x-bytemind36"))  fmt.Println(must(mime.ExtensionsByType("application/x-bytemind36")))}
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference