Commit 4d01f924 authored by Venil Noronha's avatar Venil Noronha Committed by Joe Tsai

fmt: add example for Fscanf

Change-Id: Ia3dcb3a82e452fdcf0d087e8cd01ac01ca831c84
Reviewed-on: https://go-review.googlesource.com/132597Reviewed-by: default avatarJoe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: default avatarKevin Burke <kev@inburke.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
parent 88206b89
......@@ -7,6 +7,7 @@ package fmt_test
import (
"fmt"
"os"
"strings"
)
// The Errorf function lets us use formatting features
......@@ -18,6 +19,24 @@ func ExampleErrorf() {
// Output: user "bueller" (id 17) not found
}
func ExampleFscanf() {
var (
i int
b bool
s string
)
r := strings.NewReader("5 true gophers")
n, err := fmt.Fscanf(r, "%d %t %s", &i, &b, &s)
if err != nil {
panic(err)
}
fmt.Println(i, b, s)
fmt.Println(n)
// Output:
// 5 true gophers
// 3
}
func ExampleSprintf() {
i := 30
s := "Aug"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment