io2

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2015 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const FileBufferSIze = 4096

FileBufferSIze is the buffer size of slice to store file content

Variables

This section is empty.

Functions

func BufReader

func BufReader(r io.Reader) *bufio.Reader

BufReader return a new bufio.Reader from exist io.Reader if current reader is already bufferd, return itself

func BufWriter

func BufWriter(w io.Writer) *bufio.Writer

BufWriter return a new bufio.Writer from exist io.Writer if current Writer is already bufferd, return itself

func Filter

func Filter(r io.Reader, w io.Writer, sync bool, filter LineFilterFunc) error

Filter readline from reader, after filter, if sync set at the end, and writer is non-null, write content to writer, otherwise, every read operation will followed by a write operation

return an error to stop filter, io.EOF means normal stop

func FilterRead

func FilterRead(r io.Reader, filter func(int, []byte) error) error

FilterRead filter line from reader

func NonEOF

func NonEOF(err error) error

func NopLineFilte

func NopLineFilte(_ int, line []byte) ([]byte, error)

NopLineFilter do nothing, just return the line

func WriteIfString

func WriteIfString(w io.Writer, v interface{}) (bool, error)

func WriteL

func WriteL(w io.Writer, bs ...[]byte) (n int, err error)

WriteL write a bytes list to writer, return total bytes writed

func WriteLString

func WriteLString(w io.Writer, strs ...string) (n int, err error)

WriteL write a string list to writer, return total bytes writed

func WriteString

func WriteString(w io.Writer, s string) (int, error)

func WriteStringln

func WriteStringln(w io.Writer, s string) (int, error)

WriteStringln write string to writer and append a newline character

func Writeln

func Writeln(w io.Writer, bs []byte) (int, error)

Writeln write bytes to writer and append a newline character

Types

type ErrorReader

type ErrorReader struct {
	io.Reader
	Error error
	Count int
}

func NewErrorReader

func NewErrorReader(r io.Reader) *ErrorReader

func (*ErrorReader) ClearError

func (r *ErrorReader) ClearError()

func (*ErrorReader) Read

func (r *ErrorReader) Read(data []byte) (int, error)

func (*ErrorReader) ReadDo

func (r *ErrorReader) ReadDo(data []byte, f func([]byte)) (int, error)

type ErrorWriter

type ErrorWriter struct {
	io.Writer
	Error error
	Count int
}

func NewErrorWriter

func NewErrorWriter(w io.Writer) *ErrorWriter

func (*ErrorWriter) ClearError

func (w *ErrorWriter) ClearError()

func (*ErrorWriter) Write

func (w *ErrorWriter) Write(data []byte) (int, error)

func (*ErrorWriter) WriteDo

func (w *ErrorWriter) WriteDo(data []byte, f func([]byte)) (int, error)

func (*ErrorWriter) WriteString

func (w *ErrorWriter) WriteString(s string) (int, error)

type LineFilterFunc

type LineFilterFunc func(num int, line []byte) (newLine []byte, err error)

type WriterChain

type WriterChain interface {
	io.Writer
	// Wrap add a new writer to top of chain
	Wrap(io.Writer)
	// Unwrap remove writer from top of chain, if there is only the base writer
	// nil was returned
	Unwrap() io.Writer
	// IsWrapped check whether a chain has wrapped writer
	IsWrapped() bool
	// Writer return the top writer
	Writer() io.Writer
	// BaseWriter return the base writer
	BaseWriter() io.Writer
}

func NewWriterChain

func NewWriterChain(wr io.Writer) WriterChain

NewWriterChain create a new writer chain based on given writer parameter must not be nil, otherwise, nil was returned

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL