]> Cypherpunks repositories - gostls13.git/commitdiff
fmt: add an example for Sprintf
authorVenil Noronha <veniln@vmware.com>
Thu, 30 Aug 2018 18:24:05 +0000 (12:24 -0600)
committerIan Lance Taylor <iant@golang.org>
Thu, 30 Aug 2018 18:56:34 +0000 (18:56 +0000)
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>
src/fmt/example_test.go

index c77e78809cc56ccdfa0f13aaddeed1a7a58e3abc..2d17fc69c7970c9baa8d698e1f6f9f3a38d6c840 100644 (file)
@@ -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
+}