Documentation ¶
Overview ¶
Package text provides a column-writer and general-purpose text filter.
Index ¶
Constants ¶
const ( CR = "\r" LF = "\n" CRLF = "\r\n" HT = "\t" SP = " " HTSP = "\t " Whitespace = "\t\r\n " )
const (
Eighty int = 80
)
Variables ¶
This section is empty.
Functions ¶
func ColumnWriter ¶
NewColumnWriter wraps w such that only lines of length (including sep) at most col, terminated by sep are written. This is achieved by injecting sep. After closing with Close, if any bytes were written, sep will have been the last bytes written. ColumnWriter panics if col < 0, len(sep) <= 0 or col <= len(sep).
One rule for Go text recoders is that the empty input is transformed to the empty output.
func ToCrlf ¶
Adds a trailing LF on non-zero input which is non-terminated.
func ToLf ¶
Adds a trailing CRLF on non-zero input which is non-terminated.
Types ¶
type MappedReader ¶
type MappedReader struct {
// contains filtered or unexported fields
}
func Map ¶
func Map(m Mapping, r io.Reader) *MappedReader
func (*MappedReader) Read ¶
func (mr *MappedReader) Read(p []byte) (int, error)
type Mapping ¶
type Mapping struct { // 1 <= Lookahead Lookahead int // len([]byte) == Lookahead except at EOF // len([]byte) > 0 F func(window []byte) (emit []byte, read int, err error) }
func Crlf ¶
func Crlf() Mapping
Lf maps any of the common three newline representations ("\n" (Unix), "\r\n" (mail, DOS), "\r" (old Mac OS)) and converts them to "\r\n".