mime.go
func readMimetypes(filename string) (map[string]string, error) {
	mimetypes := make(map[string]string)
	// Read the mimetype file
	data, err := ioutil.ReadFile(filename)
	if err != nil {
		return nil, err
	}
	// For each line, store extensions and mimetypes in the hash map
	for _, line := range bytes.Split(data, []byte("\n")) {
		fields := bytes.Fields(line)
		if len(fields) > 1 {
			for _, ext := range fields[1:] {
				mimetypes[string(ext)] = string(fields[0])
			}
		}
	}
	return mimetypes, nil
}
func readMimetypes(filename string) (map[string]string, error) {
	mimetypes := make(map[string]string)
	// Read the mimetype file
	data, err := ioutil.ReadFile(filename)
	if err != nil {
		return nil, err
	}
	// For each line, store extensions and mimetypes in the hash map
	for _, line := range bytes.Split(data, []byte("\n")) {
		fields := bytes.Fields(line)
		if len(fields) > 1 {
			for _, ext := range fields[1:] {
				mimetypes[string(ext)] = string(fields[0])
			}
		}
	}
	return mimetypes, nil
}
func readMimetypes ( filename string ) ( map [ string ] string , error ) { mimetypes := make ( map [ string ] string ) // Read the mimetype file data , err := ioutil . ReadFile ( filename ) if err != nil { return nil , err } // For each line, store extensions and mimetypes in the hash map for _ , line := range bytes . Split ( data , [ ] byte ( " \n " ) ) { fields := bytes . Fields ( line ) if len ( fields ) > 1 { for _ , ext := range fields [ 1 : ] { mimetypes [ string ( ext ) ] = string ( fields [ 0 ] ) } } } return mimetypes , nil }
// Read a mimetype text file. Return a hash map from ext to mimetype.
Read a mimetype text file . Return a hash map from ext to mimetype .