Skip to content

Commit 8229daf

Browse files
ucirelloLukeShu
authored andcommitted
html: add examples to the functions
Change-Id: I129d70304ae4e4694d9217826b18b341e3834d3c Reviewed-on: https://go-review.googlesource.com/11201 Reviewed-by: Andrew Gerrand <[email protected]> Cherry-picked-from: golang/go@a3c0730
1 parent 1a4b4d4 commit 8229daf

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

html/escape_example_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015 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.
4+
5+
package html_test
6+
7+
import (
8+
"fmt"
9+
"html"
10+
)
11+
12+
func ExampleEscapeString() {
13+
const s = `"Fran & Freddie's Diner" <[email protected]>`
14+
fmt.Println(html.EscapeString(s))
15+
// Output: &#34;Fran &amp; Freddie&#39;s Diner&#34; &lt;[email protected]&gt;
16+
}
17+
18+
func ExampleUnescapeString() {
19+
const s = `&quot;Fran &amp; Freddie&#39;s Diner&quot; &lt;[email protected]&gt;`
20+
fmt.Println(html.UnescapeString(s))
21+
// Output: "Fran & Freddie's Diner" <[email protected]>
22+
}

0 commit comments

Comments
 (0)