diff options
author | Venil Noronha <veniln@vmware.com> | 2018-08-30 12:24:05 -0600 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2018-08-30 18:56:34 +0000 |
commit | d3b9572759770443d6f89f8e07c1a98eec1cf769 (patch) | |
tree | fc07c69155f73abd1525743c028c0daa59e50851 /src/fmt | |
parent | f882d89b768bcfbd02b209acf0d525f4dbdd8f09 (diff) | |
download | go-d3b9572759770443d6f89f8e07c1a98eec1cf769.tar.gz go-d3b9572759770443d6f89f8e07c1a98eec1cf769.zip |
fmt: add an example for Sprintf
Signed-off-by: Venil Noronha <veniln@vmware.com>
Change-Id: Ie5f50bc31db1eee11582b70b0e25c726090d4037
Reviewed-on: https://go-review.googlesource.com/132236
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/fmt')
-rw-r--r-- | src/fmt/example_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
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 +} |