parser

package
v0.0.0-...-16fbdda Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSeparatorNotFound = fmt.Errorf("separator not found")

Functions

This section is empty.

Types

type LineParser

type LineParser interface {
	Parse(line string) (*Row, error)
}

type Parsing

type Parsing struct {
	Rows <-chan *Row
	// contains filtered or unexported fields
}

Parsing provides access to the (possibly ongoing) outcome of parser.Parse(). Clients can read new rows as they are parsed from Rows. Err() can be called before or after parsing stopped, and will return the error that caused parsing to stop, if any.

func Parse

func Parse(lp LineParser, src io.Reader) *Parsing

Parse reads src line by line, applies the LineParser to each, and writes the resulting rows to Parsing.Rows. An error from the LineParser stops reading (and writing). The error can be retrieved from Parsing.Err().

func (*Parsing) Err

func (p *Parsing) Err() error

type Row

type Row struct {
	Label string
	Cells []string
	Err   error
}

type XsvLineParser

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

func NewXsvLineParser

func NewXsvLineParser(separator string, fieldsSeparator string) *XsvLineParser

func (*XsvLineParser) Parse

func (p *XsvLineParser) Parse(line string) (*Row, error)

Jump to

Keyboard shortcuts

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