Golang bufio.NewWriter function example

package bufio

NewWriter returns a new Writer whose buffer has the default size.

Golang bufio.NewWriter function usage example

 package main

 import (
 "bufio"
 "fmt"
 "os"
 )

 func main() {
 screenWriter := bufio.NewWriter(os.Stdout)
 fmt.Fprint(screenWriter, "Hello, ")
 fmt.Fprint(screenWriter, "world! 你好世界!\n")
 screenWriter.Flush() // Don't forget to flush!
 }

Output :

Hello, world! 你好世界!

Reference :

http://golang.org/pkg/bufio/#NewWriter

Advertisement