Standard library / bufio
bufio.NewWriter()
Wraps a writer with buffering. Call Flush and check its error before considering delivery complete. Expected stdout: '0\nabc\n'.
Formal Syntax & Structure
go syntaxgo
func NewWriter(w io.Writer) *WriterParameters & Attributes
| Name | Type | Description |
|---|---|---|
| w | io.Writer | Destination writer. |
Return Value
*Writer
Wraps a writer with buffering.
Working Example
Example Snippetgo
package main
import ( "bufio" "bytes" "fmt")
func main() { var b bytes.Buffer w := bufio.NewWriter(&b) w.WriteString("abc") fmt.Println(b.Len()) if e := w.Flush(); e != nil { panic(e) } fmt.Println(b.String())}