Documentation
¶
Index ¶
Constants ¶
const Closed = errutil.Error("Closed")
Closed is used by ChunkOutput to indicate a request to close the writer. ( why not io.EOF? ChunkWriter is custom so the error can be custom too. )
Variables ¶
This section is empty.
Functions ¶
func WriteRune ¶
WriteRune helper mimics io.WriteString, this invokes RuneWriter.WriteRune if w implements it. Otherwise w.Write gets called with the bytes necessary to encode the specified rune. Returns the number of bytes written.
func WriteString ¶
WriteString helper mimics io.WriteString, invoking w.WriteString if it implements it otherwise falling back to WriteRune, if it implements it or Write otherwise. using io.WriteString is generally enough because the formatting layers use ChunkWriter which use this.
Types ¶
type Chunk ¶
type Chunk struct {
Data interface{}
}
Chunk unifies the four possible output data types: rune, byte, []rune, and string.
func (*Chunk) DecodeLastRune ¶
DecodeRune - return the last rune in the data.
func (*Chunk) DecodeRune ¶
DecodeRune - return the first rune of the data.
func (*Chunk) Reset ¶
func (c *Chunk) Reset()
Reset - forget the chunk's data; empty will return true, valid will return false.
type ChunkOutput ¶
ChunkOutput - adapts go standard output for various methods: when go writes bytes, runes, or strings; this turns them all into chunks. this is a convenience so that filters, etc. only have to implement one write method ( WriteChunk ) not the full set of go's five methods. It should return the number of bytes of the *chunk* that were consumed, and any error encountered along the way. Noting that the returned value might not match the number of bytes written if the output is padded or reduced in someway.
func (ChunkOutput) Close ¶
func (n ChunkOutput) Close() error
Close redirects the call to WriteChunk with a Closed error
func (ChunkOutput) Write ¶
func (n ChunkOutput) Write(p []byte) (int, error)
Write redirects the call to WriteChunk
func (ChunkOutput) WriteByte ¶
func (n ChunkOutput) WriteByte(b byte) error
WriteByte redirects the call to WriteChunk
func (ChunkOutput) WriteRune ¶
func (n ChunkOutput) WriteRune(q rune) (int, error)
WriteRune redirects the call to WriteChunk
func (ChunkOutput) WriteString ¶
func (n ChunkOutput) WriteString(s string) (int, error)
WriteString redirects the call to WriteChunk
type ChunkWriter ¶
ChunkWriter - adapter a regular io.Writer into a chunk writer
func (ChunkWriter) Close ¶
func (c ChunkWriter) Close() error
func (ChunkWriter) WriteByte ¶
func (c ChunkWriter) WriteByte(b byte) error
func (ChunkWriter) WriteString ¶
func (c ChunkWriter) WriteString(s string) (ret int, err error)
type Output ¶
type Output interface { Write(p []byte) (int, error) WriteByte(c byte) error WriteRune(r rune) (int, error) WriteString(s string) (int, error) }
Output defines a sink for go friendly text output. It's a subset of strings.Builder.
type OutputCloser ¶
OutputCloser - callers should attempt to Close() when they are done with a writer. ( this conforms to the io.Closer interface )