funcmain() { const name, age = "Kim", 22 n, err := fmt.Fprint(os.Stdout, name, " is ", age, " years old.\n")
// The n and err return values from Fprint are // those returned by the underlying io.Writer. if err != nil { fmt.Fprintf(os.Stderr, "Fprint: %v\n", err) } fmt.Print(n, " bytes written.\n") }
funcmain() { const name, age = "Kim", 22 n, err := fmt.Fprintf(os.Stdout, "%s is %d years old.\n", name, age)
// The n and err return values from Fprintf are // those returned by the underlying io.Writer. if err != nil { fmt.Fprintf(os.Stderr, "Fprintf: %v\n", err) } fmt.Printf("%d bytes written.\n", n) }
funcmain() { const name, age = "Kim", 22 n, err := fmt.Fprintln(os.Stdout, name, "is", age, "years old.")
// The n and err return values from Fprintln are // those returned by the underlying io.Writer. if err != nil { fmt.Fprintf(os.Stderr, "Fprintln: %v\n", err) } fmt.Println(n, "bytes written.") }