From: Venil Noronha Date: Thu, 30 Aug 2018 18:24:05 +0000 (-0600) Subject: fmt: add an example for Sprintf X-Git-Tag: go1.12beta1~1216 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d3b9572759770443d6f89f8e07c1a98eec1cf769;p=gostls13.git fmt: add an example for Sprintf Signed-off-by: Venil Noronha Change-Id: Ie5f50bc31db1eee11582b70b0e25c726090d4037 Reviewed-on: https://go-review.googlesource.com/132236 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- diff --git a/src/fmt/example_test.go b/src/fmt/example_test.go index c77e78809c..2d17fc69c7 100644 --- a/src/fmt/example_test.go +++ b/src/fmt/example_test.go @@ -27,3 +27,14 @@ func ExampleStringer() { fmt.Println(a) // Output: Gopher (2) } + +func ExampleSprintf() { + i := 30 + s := "Aug" + sf := fmt.Sprintf("Today is %d %s", i, s) + fmt.Println(sf) + fmt.Println(len(sf)) + // Output: + // Today is 30 Aug + // 15 +}