Standard library / net

net.Buffers.WriteTo()

Write remaining buffers to a writer, consuming slice headers. Some platforms optimize writes to sockets; a writer can return partial progress and an error. Expected stdout: '4 abcd 0\n'.

Formal Syntax & Structure

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

Parameters & Attributes

NameTypeDescription
wio.WriterDestination writer.

Return Value

(n int64, err error)

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt"  "net")
func main() {  v := net.Buffers{[]byte("ab"), []byte("cd")}  var b bytes.Buffer  n := must(v.WriteTo(&b))  fmt.Println(n, b.String(), len(v))}
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference