Documentation ¶
Overview ¶
Package iomisc provides miscellaneous I/O functions.
Index ¶
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 ¶
func ReadUntilMatch(ctx context.Context, m *MatchingReader) ([]byte, error)
ReadUntilMatch reads from a MatchingReader until a match has been read and returns the match. 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.
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.