Standard library / mime
mime.AddExtensionType()
Register an extension-to-media-type mapping in this process. Registration does not inspect file bytes. Expected stdout: 'application/x-bytemind36\n'.
Formal Syntax & Structure
go syntaxgo
func AddExtensionType(ext, typ string) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| ext | string | File extension including the leading dot. |
| typ | string | Media type to associate or look up. |
Return Value
error
Nil on success, otherwise the operation error.
Working Example
Example Snippetgo
package main
import ( "fmt" "mime")
func main() { check(mime.AddExtensionType(".bytemind36", "application/x-bytemind36")) fmt.Println(mime.TypeByExtension(".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) }}