utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHeader

func CreateHeader(columns []string, fieldColumnMap map[string]string) (map[string]int, error)

CreateHeader creates header from columns. Using fieldColumnMap to filter only requested field and also rename it.

func ProvideField

func ProvideField(fieldColumnMap map[string]int, row []string) (map[string]interface{}, error)

ProvideField provides row to be accessed by field names using map. The returned map will only provide the specified fields.

func StringToNullBool

func StringToNullBool(s string) (sql.NullBool, error)

StringToNullBool converts string to sql.NullBool

func StringToNullFloat64

func StringToNullFloat64(s string) (sql.NullFloat64, error)

StringToNullFloat64 converts string to sql.NullFloat64

func StringToNullInt32

func StringToNullInt32(s string) (sql.NullInt32, error)

StringToNullInt32 converts string to sql.NullInt32

func StringToNullInt64

func StringToNullInt64(s string) (sql.NullInt64, error)

StringToNullInt64 converts string to sql.NullInt64

func StringToNullString

func StringToNullString(s string) (sql.NullString, error)

StringToNullString converts string to sql.NullString

func StringToNullTime

func StringToNullTime(layout, s string) (sql.NullTime, error)

StringToNullTime converts string to sql.NullTime

func StringToTime

func StringToTime(layout, s string) (time.Time, error)

StringToTime converts string to time.Time

Types

type FieldError

type FieldError struct {
	Field   string
	Message string
}

FieldError records an error that happens in a field.

func ErrEmptyValue

func ErrEmptyValue(field string) FieldError

ErrEmptyValue indicates an empty value error

func (FieldError) Error

func (e FieldError) Error() string

type RecordError

type RecordError struct {
	Source    string
	RecordNum int64
	Message   string
}

RecordError records an error that happens in a record.

func (RecordError) Error

func (e RecordError) Error() string

type SourceFieldError added in v0.1.11

type SourceFieldError struct {
	Source    string
	RecordNum int64
	FieldError
}

SourceFieldError records an error that happen when converting field value.

func (SourceFieldError) Error added in v0.1.11

func (e SourceFieldError) Error() string

type SourceGenericError added in v0.1.11

type SourceGenericError struct {
	Source    string
	RecordNum int64
	Message   string
}

SourceGenericError records a generic error that happen when processing csv file.

func (SourceGenericError) Error added in v0.1.11

func (e SourceGenericError) Error() string

Jump to

Keyboard shortcuts

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