Documentation ¶
Index ¶
- func CountLines(file string) (int, error)
- func DupReadCloser(reader io.ReadCloser) (io.ReadCloser, io.ReadCloser)
- func NopCloser(w io.Writer) io.WriteCloser
- func ReadBytes(reader io.Reader, buf []byte) error
- func ReadText(filename string) (string, error)
- func ReadTextLines(filename string, opts ...TextReadOption) ([]string, error)
- func RedirectInOut() (restore func(), err error)
- type BufferPool
- type TextLineScanner
- type TextReadOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountLines ¶
func DupReadCloser ¶
func DupReadCloser(reader io.ReadCloser) (io.ReadCloser, io.ReadCloser)
The first returned reader needs to be read first, because the content read from it will be written to the underlying buffer of the second reader.
func ReadTextLines ¶
func ReadTextLines(filename string, opts ...TextReadOption) ([]string, error)
func RedirectInOut ¶
func RedirectInOut() (restore func(), err error)
RedirectInOut redirects stdin to r, stdout to w, and callers need to call restore afterwards.
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
func NewBufferPool ¶
func NewBufferPool(capability int) *BufferPool
func (*BufferPool) Get ¶
func (bp *BufferPool) Get() *bytes.Buffer
func (*BufferPool) Put ¶
func (bp *BufferPool) Put(buf *bytes.Buffer)
type TextLineScanner ¶
type TextLineScanner struct {
// contains filtered or unexported fields
}
func NewTextLineScanner ¶
func NewTextLineScanner(reader io.Reader) *TextLineScanner
func (*TextLineScanner) Line ¶
func (scanner *TextLineScanner) Line() (string, error)
func (*TextLineScanner) Scan ¶
func (scanner *TextLineScanner) Scan() bool
type TextReadOption ¶
type TextReadOption func(*textReadOptions)
func KeepSpace ¶
func KeepSpace() TextReadOption
func OmitWithPrefix ¶
func OmitWithPrefix(prefix string) TextReadOption
func WithoutBlank ¶
func WithoutBlank() TextReadOption
Click to show internal directories.
Click to hide internal directories.