ios

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 8 Imported by: 18

Documentation

Index

Constants

View Source
const (
	// ScannerByDelimFlagEofAsDelim specifies that the scanner should treat EOF as the delimiter as well.
	ScannerByDelimFlagEofAsDelim ScannerByDelimFlag = 1 << iota
	// ScannerByDelimFlagDropDelimInReturn specifies that the delimiter should NOT be included in the return value.
	ScannerByDelimFlagDropDelimInReturn

	// ScannerByDelimFlagEofNotAsDelim specifies that the scanner should NOT treat EOF as the delimiter.
	ScannerByDelimFlagEofNotAsDelim = 0
	// ScannerByDelimFlagIncludeDelimInReturn specifies that the delimiter should be included in the return value.
	ScannerByDelimFlagIncludeDelimInReturn = 0
)
View Source
const (
	// ScannerByDelimFlagDefault specifies the most commonly used flags for the scanner.
	ScannerByDelimFlagDefault = ScannerByDelimFlagEofAsDelim | ScannerByDelimFlagDropDelimInReturn
)

Variables

This section is empty.

Functions

func DirExists added in v0.0.4

func DirExists(dir string) bool

DirExists checks if a directory exists or not.

func FileExists added in v0.0.4

func FileExists(file string) bool

FileExists checks if a file exists or not.

func NewScannerByDelim

func NewScannerByDelim(r io.Reader, delim string, flags ScannerByDelimFlag) *bufio.Scanner

NewScannerByDelim creates a scanner that returns tokens from the source reader separated by a delimiter.

func NewScannerByDelim2

func NewScannerByDelim2(r io.Reader, delim string, escape *rune, flags ScannerByDelimFlag) *bufio.Scanner

NewScannerByDelim2 creates a scanner that returns tokens from the source reader separated by a delimiter, with consideration of potential presence of escaping sequence. Note: the token returned from the scanner will **NOT** do any unescaping, thus keeping the original value.

func ReadLine

func ReadLine(r *bufio.Reader) (string, error)

ReadLine reads in a single line from a bufio.Reader.

func StripBOM

func StripBOM(reader io.Reader) (io.Reader, error)

StripBOM returns a new io.Reader that, if needed, strips away the BOM (byte order marker) of the input io.Reader.

Types

type BytesReplacingReader

type BytesReplacingReader struct {
	// contains filtered or unexported fields
}

BytesReplacingReader allows transparent replacement of a given token during read operation.

func NewBytesReplacingReader

func NewBytesReplacingReader(r io.Reader, search, replace []byte) *BytesReplacingReader

NewBytesReplacingReader creates a new `*BytesReplacingReader`. `search` cannot be nil/empty. `replace` can.

func (*BytesReplacingReader) Read

func (r *BytesReplacingReader) Read(p []byte) (int, error)

Read implements the `io.Reader` interface.

func (*BytesReplacingReader) Reset

func (r *BytesReplacingReader) Reset(r1 io.Reader, search1, replace1 []byte) *BytesReplacingReader

Reset allows reuse of a previous allocated `*BytesReplacingReader` for buf allocation optimization. `search` cannot be nil/empty. `replace` can.

type LineCountingReader

type LineCountingReader struct {
	// contains filtered or unexported fields
}

LineCountingReader wraps an io.Reader and reports currently which line the reader is at. Note the LineAt starts a 1.

func NewLineCountingReader

func NewLineCountingReader(r io.Reader) *LineCountingReader

NewLineCountingReader creates new LineCountingReader wrapping around an input io.Reader.

func (*LineCountingReader) AtLine

func (r *LineCountingReader) AtLine() int

AtLine returns the current line number. Note it starts with 1.

func (*LineCountingReader) Read

func (r *LineCountingReader) Read(p []byte) (n int, err error)

Read implements the `io.Reader` interface.

type LineNumReportingCsvReader

type LineNumReportingCsvReader struct {
	*csv.Reader
	// contains filtered or unexported fields
}

LineNumReportingCsvReader wraps std lib `*csv.Reader` and exposes the current line number.

func NewLineNumReportingCsvReader

func NewLineNumReportingCsvReader(r io.Reader) *LineNumReportingCsvReader

NewLineNumReportingCsvReader creates a new `*LineNumReportingCsvReader`.

func (*LineNumReportingCsvReader) LineNum

func (r *LineNumReportingCsvReader) LineNum() int

LineNum returns the current line number

type ScannerByDelimFlag

type ScannerByDelimFlag uint

ScannerByDelimFlag is the type of flags passed to NewScannerByDelim/NewScannerByDelim2.

Jump to

Keyboard shortcuts

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