parser

package
v0.0.0-...-f6b5bb9 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultParser

type DefaultParser struct {
}

func (*DefaultParser) CSVHeader

func (p *DefaultParser) CSVHeader(regexps []*regexp.Regexp) []string

CSVHeader builds a slice out of named groups within a list of regexes.

func (*DefaultParser) CompileRegex

func (p *DefaultParser) CompileRegex(fields []string) ([]*regexp.Regexp, error)

CompileRegex compiles regexes based on field names which may include a colon.

func (*DefaultParser) NamedGroup

func (p *DefaultParser) NamedGroup(field string) string

NamedGroup converts a field into a name that can be used in a named group.

func (*DefaultParser) Parse

func (p *DefaultParser) Parse(fields []string, b []byte) (*bytes.Buffer, error)

Parse parses fields out of a slice of bytes into CSV.

func (*DefaultParser) Save

func (p *DefaultParser) Save(buf *bytes.Buffer, filename string) error

Save saves a buffer of bytes to a file.

type Parser

type Parser interface {
	CompileRegex(fields []string) ([]*regexp.Regexp, error)
	Parse(fields []string, b []byte) (*bytes.Buffer, error)
	CSVHeader(regexps []*regexp.Regexp) []string
	NamedGroup(field string) string
	Save(buf *bytes.Buffer, filename string) error
}

Jump to

Keyboard shortcuts

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