diff options
Diffstat (limited to 'src/mime/example_test.go')
-rw-r--r-- | src/mime/example_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mime/example_test.go b/src/mime/example_test.go index c7d13cdcdb..85795976f0 100644 --- a/src/mime/example_test.go +++ b/src/mime/example_test.go @@ -96,3 +96,29 @@ func ExampleWordDecoder_DecodeHeader() { // ¡Hola, señor! // HELLO WORLD! } + +func ExampleFormatMediaType() { + mediatype := "text/html" + params := map[string]string{ + "charset": "utf-8", + } + + result := mime.FormatMediaType(mediatype, params) + + fmt.Println("result:", result) + // Output: + // result: text/html; charset=utf-8 +} + +func ExampleParseMediaType() { + mediatype, params, err := mime.ParseMediaType("text/html; charset=utf-8") + if err != nil { + panic(err) + } + + fmt.Println("type:", mediatype) + fmt.Println("charset:", params["charset"]) + // Output: + // type: text/html + // charset: utf-8 +} |