mirror of
https://github.com/golang/go
synced 2024-11-23 17:40:03 -07:00
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>
This commit is contained in:
parent
f882d89b76
commit
d3b9572759
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user