1
2
3
4
5 package textproto_test
6
7 import (
8 "bufio"
9 "fmt"
10 "net/textproto"
11 "strings"
12 )
13
14 func ExampleReader_ReadMIMEHeader() {
15 input := "content-type: text/plain\r\n" +
16 "x-tag: one\r\n" +
17 "x-tag: two\r\n" +
18 "long-key: Even\r\n" +
19 "\tLonger Value\r\n\r\n"
20 r := textproto.NewReader(bufio.NewReader(strings.NewReader(input)))
21
22 header, err := r.ReadMIMEHeader()
23 if err != nil {
24 panic(err)
25 }
26 fmt.Println(header["Content-Type"][0])
27 fmt.Println(header["X-Tag"])
28 fmt.Println(header["Long-Key"])
29
30
31
32
33
34 }
35
View as plain text