]> Cypherpunks.ru repositories - gostls13.git/commitdiff
fmt: add example for Fprint
authorThanabodee Charoenpiriyakij <wingyminus@gmail.com>
Wed, 5 Sep 2018 06:40:29 +0000 (13:40 +0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 7 Sep 2018 11:14:53 +0000 (11:14 +0000)
Updates #27376

Change-Id: I0ceb672a9fcd7bbf491be1577d7f135ef35b2561
Reviewed-on: https://go-review.googlesource.com/133455
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 1479b761b6e0f03422a3dad79f7977292ad9db30..6aeee03e43a93df8fdc2eb8c195ed4dcdc7a935a 100644 (file)
@@ -68,6 +68,17 @@ func ExampleSprintln() {
        // "Today is 30 Aug\n"
 }
 
+func ExampleFprint() {
+       n, err := fmt.Fprint(os.Stdout, "there", "are", 99, "gophers", "\n")
+       if err != nil {
+               panic(err)
+       }
+       fmt.Print(n)
+       // Output:
+       // thereare99gophers
+       // 18
+}
+
 func ExampleFprintln() {
        n, err := fmt.Fprintln(os.Stdout, "there", "are", 99, "gophers")
        if err != nil {