Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // MaxLinesErr is an instance of MaxLinesError that gets returned by // Write() whenever the number of lines written has exceeded the number // in |MaxLineWriter.MaxLines|. MaxLinesErr = MaxLinesError{"Maximum number of lines written"} )
Functions ¶
This section is empty.
Types ¶
type MaxLineWriter ¶
MaxLineWriter provides an io.Writer interface that counts the number of lines that have been written. It will stop writing and returns an error if the number of lines written exceeds the number specified in MaxLineWriter.NumLines.
func (*MaxLineWriter) Write ¶
func (w *MaxLineWriter) Write(data []byte) (int, error)
Write() stops writing and returns an error if an attempt is made to write any byte after |MaxLines| newLines have been written. For example, if MaxLines is 1, all bytes will be written up to and including the 1st newline. If there are any bytes in |data| after the 1st newline, an error will be returned.
Callers can change the value of |w.MaxLines| before any call to Write(). Setting MaxLines to 0 will allow any number of newLines.
type MaxLinesError ¶
type MaxLinesError struct {
// contains filtered or unexported fields
}
MaxLinesError is the type of error returned by Write() whenever the number of lines written has exceeded the number in |MaxLineWriter.MaxLines|.
func (MaxLinesError) Error ¶
func (e MaxLinesError) Error() string
type PrefixWriter ¶
type PrefixWriter struct { Dest io.Writer PrefixFunc func(w *PrefixWriter) []byte NeedsPrefix bool NumLines uint32 }
PrefixWriter makes it easy to prefix lines with a custom prefix. Each time it writes a byte after a newline('\n') character it calls PrefixFunc() to get the byte slice that should be written. |NeedsPrefix| can be set to true to cause a prefix to be written immediately. This is useful for causing a prefix to get written on the first line.