Standard library / bufio
bufio.Writer.Reset()
Discards unflushed data, clears stored errors and switches destination; flush first if data must be retained. Expected stdout: '0 ok\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Writer) Reset(w io.Writer)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| w | io.Writer | Destination writer. |
Working Example
Example Snippetgo
package main
import ( "bufio" "bytes" "fmt")
func main() { var a, b bytes.Buffer w := bufio.NewWriter(&a) w.WriteString("lost") w.Reset(&b) w.WriteString("ok") w.Flush() fmt.Println(a.Len(), b.String())}