Documentation ¶
Index ¶
- func BytesToReadCloser(b []byte) io.ReadCloser
- func CopyEx(dst io.Writer, dstWriteCb SetDeadlineCallback, src io.Reader, ...) (written int64, err error)
- func CopyTimeout(dst io.Writer, src io.Reader, noDataTimeout time.Duration) (written int64, err error)
- func Read(r io.Reader, buf []byte, timeout *time.Duration) (n int, err error)
- func ReadAtLeast(r io.Reader, buf []byte, min int, timeout *time.Duration) (n int, err error)
- func ReadCloserToBytes(rd io.ReadCloser) ([]byte, error)
- func ReadCloserToInterface(rd io.ReadCloser) (interface{}, error)
- func ReadCloserToString(rd io.ReadCloser) (string, error)
- func ReadFrom(dst *bytes.Buffer, src io.Reader, timeout *time.Duration) (n int64, err error)
- func ReadFull(r io.Reader, buf []byte, timeout *time.Duration) (n int, err error)
- func ReadHead(r io.Reader, timeout *time.Duration) (*bytes.Buffer, error)
- func ReadLine(r io.Reader, keepN bool, maxSize int) ([]byte, error)
- func ReadUntil(r io.Reader, delim byte, keepDelim bool, maxSize int) ([]byte, error)
- func ReaderToBytes(rd io.Reader) ([]byte, error)
- func ReaderToString(rd io.Reader) (string, error)
- func StringToReadCloser(s string) io.ReadCloser
- func TwoWaysCopy(s1, s2 io.ReadWriteCloser, errNotify ErrNotify)
- type BufEx
- type CopiedSizeCallback
- type ErrNotify
- type Flusher
- type NormalReader
- type ReaderTimeout
- type RewindReader
- type SetDeadlineCallback
- type SniffBuf
- type TimeoutR
- type TimeoutReadCloser
- type TimeoutReadWriteCloser
- type TimeoutW
- type TimeoutWriteCloser
- type WriteFlushCloser
- type WriteFlusher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToReadCloser ¶
func BytesToReadCloser(b []byte) io.ReadCloser
func CopyEx ¶
func CopyEx(dst io.Writer, dstWriteCb SetDeadlineCallback, src io.Reader, srcReadCb SetDeadlineCallback, timeout time.Duration, sizeCallback CopiedSizeCallback) (written int64, err error)
https://github.com/efarrer/iothrottler/ https://github.com/jwkohnen/bwio/ limit copy speed / duration, read copied size
func CopyTimeout ¶
func CopyTimeout(dst io.Writer, src io.Reader, noDataTimeout time.Duration) (written int64, err error)
CopyTimeout is a Copy function with no data timeout parameter. Note: among the two, 'dst' and 'src', there must be at least one net.Conn More: https://groups.google.com/g/golang-nuts/c/byfD0YtIl0I
func ReadAtLeast ¶
ReadAtLeast is based on standard io library.
func ReadCloserToBytes ¶
func ReadCloserToBytes(rd io.ReadCloser) ([]byte, error)
func ReadCloserToInterface ¶
func ReadCloserToInterface(rd io.ReadCloser) (interface{}, error)
func ReadCloserToString ¶
func ReadCloserToString(rd io.ReadCloser) (string, error)
func ReadFull ¶
ReadFull reads from r into buf, until exactly len(buf) bytes read, or error returned, including gerrors.ErrTimeout, io.EOF, io.ErrUnexpectedEOF, and any other type of error.
func ReadLine ¶
ReadLine reads from r into buf, until '\n' read, or maxSize read, or error returned, including io.EOF, io.ErrUnexpectedEOF, and any other type of error. Note: this function is slow, DO NOT call this function too often!
func ReadUntil ¶
ReadUntil reads until the first occurrence of delim in the input, or maxSize read, or error returned, including io.EOF, io.ErrUnexpectedEOF, and any other type of error. Note: this function is slow, DO NOT call this function too often!
func StringToReadCloser ¶
func StringToReadCloser(s string) io.ReadCloser
func TwoWaysCopy ¶
func TwoWaysCopy(s1, s2 io.ReadWriteCloser, errNotify ErrNotify)
Types ¶
type CopiedSizeCallback ¶
type CopiedSizeCallback func(size int64)
type NormalReader ¶
type NormalReader SniffBuf // normal reader which isn't rewindable
type ReaderTimeout ¶
type ReaderTimeout interface { io.ReadCloser SetReadDeadline(t time.Time) error }
type RewindReader ¶
type RewindReader SniffBuf // special reader which is rewindable
type SetDeadlineCallback ¶
type SniffBuf ¶
type SniffBuf struct {
// contains filtered or unexported fields
}
func (*SniffBuf) NormalReader ¶
func (sc *SniffBuf) NormalReader() *NormalReader
NormalReader exports a normal io.Reader
func (*SniffBuf) RewindReader ¶
func (sc *SniffBuf) RewindReader() *RewindReader
RewindReader exports a RewindReader
type TimeoutReadCloser ¶
type TimeoutReadCloser interface { io.ReadCloser SetReadDeadline(t time.Time) error }
type TimeoutReadWriteCloser ¶
type TimeoutWriteCloser ¶
type TimeoutWriteCloser interface { io.WriteCloser SetWriteDeadline(t time.Time) error }