mirror of https://github.com/golang/go.git
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>
This commit is contained in:
parent
d5c7abf73a
commit
796e4bdc6b
|
|
@ -6,6 +6,7 @@ package fmt_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The Errorf function lets us use formatting features
|
// The Errorf function lets us use formatting features
|
||||||
|
|
@ -27,3 +28,14 @@ func ExampleSprintf() {
|
||||||
// Today is 30 Aug
|
// Today is 30 Aug
|
||||||
// 15
|
// 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
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue