diff options
author | Dylan Waits <dylan@waits.io> | 2018-08-30 13:04:09 -0600 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-08-30 20:12:14 +0000 |
commit | 796e4bdc6b3edef2d838ddc3c4d35aee3f8e89cc (patch) | |
tree | 72e3eee12c23e031821a986414d70fc715ad1407 /src/fmt | |
parent | d5c7abf73a3f65cb7d5b9c3193e59ac9e0729c7a (diff) | |
download | go-796e4bdc6b3edef2d838ddc3c4d35aee3f8e89cc.tar.gz go-796e4bdc6b3edef2d838ddc3c4d35aee3f8e89cc.zip |
fmt: add example for Fprintln
Change-Id: Idc4aa53e443b89eeba496d00f6b409268e29ec21
Reviewed-on: https://go-review.googlesource.com/132241
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/fmt')
-rw-r--r-- | src/fmt/example_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/fmt/example_test.go b/src/fmt/example_test.go index 5797e48080..7b7eacafb4 100644 --- a/src/fmt/example_test.go +++ b/src/fmt/example_test.go @@ -6,6 +6,7 @@ package fmt_test import ( "fmt" + "os" ) // The Errorf function lets us use formatting features @@ -27,3 +28,14 @@ func ExampleSprintf() { // Today is 30 Aug // 15 } + +func ExampleFprintln() { + n, err := fmt.Fprintln(os.Stdout, "there", "are", 99, "gophers") + if err != nil { + panic("failed writing to stdout, someting is seriously wrong") + } + fmt.Print(n) + // Output: + // there are 99 gophers + // 21 +} |