utils

package
v0.0.0-...-2db7ed4 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2018 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBrowserRequest

func NewBrowserRequest(method, requestURL string, optionalBody io.Reader) (*http.Request, error)

NewBrowserRequest creates new http request looking like coming from Firefox

func ParseCZFloat

func ParseCZFloat(str string) (float64, error)

ParseCZFloat parses string as czech float format

func StringPreview

func StringPreview(str string, maxRunes int) string

StringPreview returns str shortened to max maxRunes including optional ellipsis character

Types

type CSVReader

type CSVReader struct {

	// Comma specifies the delimiter used to separate columns (default is ',')
	Comma rune
	// MinimumHeaderSeparators is the least amount of Comma in a line to consider
	// the line being a header
	MinimumHeaderSeparators int
	// contains filtered or unexported fields
}

CSVReader can read CSV files with header line. It is able to skip the garbage before the first valid CSV line (header). A valid header line contains at least MinimumHeaderSeparators column delimiters specified by Comma

func NewCSVReader

func NewCSVReader(r io.Reader) *CSVReader

NewCSVReader creates a new CSV reader object

func NewCSVReaderWithEncoding

func NewCSVReaderWithEncoding(r io.Reader, encoding encoding.Encoding) *CSVReader

NewCSVReaderWithEncoding creates a new CSV reader object with encoding interface. For encoding it is possible to use https://godoc.org/golang.org/x/text/encoding/charmap

func (*CSVReader) Garbage

func (r *CSVReader) Garbage() []byte

Garbage returns the garbage bytes before the header line

func (*CSVReader) GarbageString

func (r *CSVReader) GarbageString() string

GarbageString returns the garbage before the header line as string

func (*CSVReader) GoCSVReader

func (r *CSVReader) GoCSVReader() *csv.Reader

GoCSVReader returns csv.Reader

func (*CSVReader) Read

func (r *CSVReader) Read(dest []byte) (n int, err error)

func (*CSVReader) Unmarshal

func (r *CSVReader) Unmarshal(out interface{}) error

Unmarshal parses the CSV from the reader to the interface, skipping the garbage before the CSV header.

type CZFloat64String

type CZFloat64String struct {
	// Float64 returns inner value
	Float64 float64
}

CZFloat64String represents a 64bit float encoded as a string in Czech format (1 234, 56)

func (*CZFloat64String) String

func (fs *CZFloat64String) String() string

func (*CZFloat64String) UnmarshalCSV

func (fs *CZFloat64String) UnmarshalCSV(csv string) (err error)

UnmarshalCSV unmarshals the value fron the CSV

func (*CZFloat64String) UnmarshalJSON

func (fs *CZFloat64String) UnmarshalJSON(inp []byte) (err error)

UnmarshalJSON unmarshals the value fron the JSON

type Float64String

type Float64String struct {
	// Float64 returns inner value
	Float64 float64
}

Float64String represents a 64bit float encoded as a string in computer format (12345.678)

func (*Float64String) String

func (fs *Float64String) String() string

func (*Float64String) UnmarshalCSV

func (fs *Float64String) UnmarshalCSV(str string) (err error)

UnmarshalCSV unmarshals the value fron the CSV

func (*Float64String) UnmarshalJSON

func (fs *Float64String) UnmarshalJSON(inp []byte) (err error)

UnmarshalJSON unmarshals the value fron the JSON

Jump to

Keyboard shortcuts

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