From d3b9572759770443d6f89f8e07c1a98eec1cf769 Mon Sep 17 00:00:00 2001 From: Venil Noronha Date: Thu, 30 Aug 2018 12:24:05 -0600 Subject: [PATCH] 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 --- src/fmt/example_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/fmt/example_test.go b/src/fmt/example_test.go index c77e78809cc..2d17fc69c79 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 +}