writerutil - ActiveState ActiveGo 1.8

Package writerutil

import "go4.org/writerutil"

Overview ▾

Package writerutil contains io.Writer types.

type PrefixSuffixSaver

PrefixSuffixSaver is an io.Writer which retains the first N bytes and the last N bytes written to it. The Bytes method reconstructs it with a pretty error message. It is copied from os/exec/exec.go of the Go stdlib.

type PrefixSuffixSaver struct {
    N int // max size of prefix or suffix
    // contains filtered or unexported fields

func (*PrefixSuffixSaver) Bytes

func (w *PrefixSuffixSaver) Bytes() []byte

Bytes returns a slice of the bytes, or a copy of the bytes, retained by w. If more bytes than could be retained were written to w, it returns a concatenation of the N first bytes, a message for how many bytes were dropped, and the N last bytes.

func (*PrefixSuffixSaver) Write

func (w *PrefixSuffixSaver) Write(p []byte) (n int, err error)