aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/strconv/example_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/strconv/example_test.go b/src/strconv/example_test.go
index b02392de6a..428fde4e66 100644
--- a/src/strconv/example_test.go
+++ b/src/strconv/example_test.go
@@ -369,6 +369,23 @@ func ExampleQuoteToGraphic() {
// "\" This is a ☺ \\n \""
}
+func ExampleQuotedPrefix() {
+ s, err := strconv.QuotedPrefix("not a quoted string")
+ fmt.Printf("%q, %v\n", s, err)
+ s, err = strconv.QuotedPrefix("\"double-quoted string\" with trailing text")
+ fmt.Printf("%q, %v\n", s, err)
+ s, err = strconv.QuotedPrefix("`or backquoted` with more trailing text")
+ fmt.Printf("%q, %v\n", s, err)
+ s, err = strconv.QuotedPrefix("'\u263a' is also okay")
+ fmt.Printf("%q, %v\n", s, err)
+
+ // Output:
+ // "", invalid syntax
+ // "\"double-quoted string\"", <nil>
+ // "`or backquoted`", <nil>
+ // "'☺'", <nil>
+}
+
func ExampleUnquote() {
s, err := strconv.Unquote("You can't unquote a string without quotes")
fmt.Printf("%q, %v\n", s, err)