S/390: Fix vector all/any cc modes.
[official-gcc.git] / libgo / go / mime / type_plan9.go
blob14ff973405186392163ed42dd5db5b1d6e47fec7
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.
5 package mime
7 import (
8 "bufio"
9 "os"
10 "strings"
13 func init() {
14 osInitMime = initMimePlan9
17 func initMimePlan9() {
18 for _, filename := range typeFiles {
19 loadMimeFile(filename)
23 var typeFiles = []string{
24 "/sys/lib/mimetype",
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",
32 ".pNg": "image/png",
36 func loadMimeFile(filename string) {
37 f, err := os.Open(filename)
38 if err != nil {
39 return
41 defer f.Close()
43 scanner := bufio.NewScanner(f)
44 for scanner.Scan() {
45 fields := strings.Fields(scanner.Text())
46 if len(fields) <= 2 || fields[0][0] != '.' {
47 continue
49 if fields[1] == "-" || fields[2] == "-" {
50 continue
52 setExtensionType(fields[0], fields[1]+"/"+fields[2])
54 if err := scanner.Err(); err != nil {
55 panic(err)