1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 osInitMime
= initMimePlan9
17 func initMimePlan9() {
18 for _
, filename
:= range typeFiles
{
19 loadMimeFile(filename
)
23 var typeFiles
= []string{
27 func initMimeForTests() map[string]string {
28 typeFiles
= []string{"testdata/test.types.plan9"}
29 return map[string]string{
30 ".t1": "application/test",
31 ".t2": "text/test; charset=utf-8",
36 func loadMimeFile(filename
string) {
37 f
, err
:= os
.Open(filename
)
43 scanner
:= bufio
.NewScanner(f
)
45 fields
:= strings
.Fields(scanner
.Text())
46 if len(fields
) <= 2 || fields
[0][0] != '.' {
49 if fields
[1] == "-" || fields
[2] == "-" {
52 setExtensionType(fields
[0], fields
[1]+"/"+fields
[2])
54 if err
:= scanner
.Err(); err
!= nil {