Standard library / bufio

bufio.Reader.WriteTo()

Streams remaining buffered and underlying data to a writer until EOF or error; returns bytes written and error. Expected stdout: '3 abc <nil>\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Reader) WriteTo(w io.Writer) (n int64, err error)

Parameters & Attributes

NameTypeDescription
wio.WriterDestination writer.

Return Value

(n int64, err error)

Streams remaining buffered and underlying data to a writer until EOF or error; returns bytes written and error.

Working Example

Example Snippetgo
package main
import (  "bufio"  "bytes"  "fmt"  "strings")
func main() {  r := bufio.NewReader(strings.NewReader("abc"))  var b bytes.Buffer  n, e := r.WriteTo(&b)  fmt.Println(n, b.String(), e)}
Go Reference