# package mime
`import "mime"`
mime实现了MIME的部分规定。
## Index
* [func AddExtensionType(ext, typ string) error](#AddExtensionType)
* [func FormatMediaType(t string, param map[string]string) string](#FormatMediaType)
* [func ParseMediaType(v string) (mediatype string, params map[string]string, err error)](#ParseMediaType)
* [func TypeByExtension(ext string) string](#TypeByExtension)
## func [AddExtensionType](https://github.com/golang/go/blob/master/src/mime/type.go#L56 "View Source")
```
func AddExtensionType(ext, typ string) error
```
函数将扩展名和mimetype建立偶联;扩展名应以点号开始,例如".html"。
## func [FormatMediaType](https://github.com/golang/go/blob/master/src/mime/mediatype.go#L21 "View Source")
```
func FormatMediaType(t string, param map[string]string) string
```
函数根据[RFC 2045](http://tools.ietf.org/html/rfc2045)和 [RFC 2616](http://tools.ietf.org/html/rfc2616)的规定将媒体类型t和参数param连接为一个mime媒体类型,类型和参数都采用小写字母。任一个参数不合法都会返回空字符串。
## func [ParseMediaType](https://github.com/golang/go/blob/master/src/mime/mediatype.go#L101 "View Source")
```
func ParseMediaType(v string) (mediatype string, params map[string]string, err error)
```
函数根据[RFC 1521](http://tools.ietf.org/html/rfc1521)解析一个媒体类型值以及可能的参数。媒体类型值一般应为Content-Type和Conten-Disposition头域的值(参见[RFC 2183](http://tools.ietf.org/html/rfc2183))。成功的调用会返回小写字母、去空格的媒体类型和一个非空的map。返回的map映射小写字母的属性和对应的属性值。
## func [TypeByExtension](https://github.com/golang/go/blob/master/src/mime/type.go#L45 "View Source")
```
func TypeByExtension(ext string) string
```
函数返回与扩展名偶联的MIME类型。扩展名应以点号开始,如".html"。如果扩展名未偶联类型,函数会返回""。
内建的偶联表很小,但在unix系统会从本地系统的一或多个mime.types文件(参加下表)进行增补。
```
/etc/mime.types
/etc/apache2/mime.types
/etc/apache/mime.types
```
Windows系统的mime类型从注册表获取。文本类型的字符集参数默认设置为"utf-8"。
- 库
- package achive
- package tar
- package zip
- package bufio
- package builtin
- package bytes
- package compress
- package bzip2
- package flate
- package gzip
- package lzw
- package zlib
- package container
- package heap
- package list
- package ring
- package crypto
- package aes
- package cipher
- package des
- package dsa
- package ecdsa
- package elliptic
- package hmac
- package md5
- package rand
- package rc4
- package rsa
- package sha1
- package sha256
- package sha512
- package subtle
- package tls
- package x509
- package pkix
- package database
- package sql
- package driver
- package encoding
- package ascii85
- package asn1
- package base32
- package base64
- package binary
- package csv
- package gob
- package hex
- package json
- package pem
- package xml
- package errors
- package expvar
- package flag
- package fmt
- package go
- package doc
- package format
- package parser
- package printer
- package hash
- package adler32
- package crc32
- package crc64
- package fnv
- package html
- package template
- package image
- package color
- package palette
- package draw
- package gif
- package jpeg
- package png
- package index
- package suffixarray
- package io
- package ioutil
- package log
- package syslog
- package math
- package big
- package cmplx
- package rand
- package mime
- package multipart
- package net
- package http
- package cgi
- package cookiejar
- package fcgi
- package httptest
- package httputil
- package pprof
- package mail
- package rpc
- package jsonrpc
- package smtp
- package textproto
- package url
- package os
- package exec
- package signal
- package user
- package path
- package filepath
- package reflect
- package regexp
- package runtime
- package cgo
- package debug
- package pprof
- package race
- package sort
- package strconv
- package strings
- package sync
- package atomic
- package text
- package scanner
- package tabwriter
- package template
- package time
- package unicode
- package utf16
- package utf8
- package unsafe