Documentation
¶
Overview ¶
Package iomisc provides miscellaneous I/O functions.
Index ¶
- func MultiCloser(closers ...io.Closer) io.Closer
- func ReadUntilMatch(ctx context.Context, reader io.Reader, toMatch ...[]byte) ([]byte, error)
- func ReadUntilMatchString(ctx context.Context, reader io.Reader, strings ...string) (string, error)
- func ReaderAtToReader(r io.ReaderAt) io.Reader
- type MatchingReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MultiCloser ¶
MultiCloser returns an io.Closer that is the logical concatenation of the provided input closers. They are closed sequentially in the provided order. It is guaranteed that all underlying closers will be closed.
func ReadUntilMatch ¶
ReadUntilMatch reads from a Reader until it encounters an occurrence of one of the byte slices specified in toMatch. Checks ctx for cancellation only between calls to m.Read(), so cancellation will not be noticed if m.Read() blocks. See https://github.com/golang/go/issues/20280 for discussion of similar issues.
func ReadUntilMatchString ¶
ReadUntilMatchString has identical behavior to ReadUntilMatch, but accepts and returns strings instead of byte slices.
Types ¶
type MatchingReader ¶
type MatchingReader struct {
// contains filtered or unexported fields
}
MatchingReader is an io.Reader implementation that wraps another such implementation. It reads only up until one of the sequences has been read consecutively.
func NewMatchingReader ¶
func NewMatchingReader(reader io.Reader, toMatch ...[]byte) *MatchingReader
NewMatchingReader returns a MatchingReader that matches any of toMatch.
func (*MatchingReader) Match ¶
func (m *MatchingReader) Match() []byte
Match returns the first match among the bytes read, or nil if there has yet to be a match.