csvhelper

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CsvDefaultConverter = "coverter:"
View Source
const CsvHeader = "header:"
View Source
const CsvHide = "hide:"
View Source
const CsvSort = "sort:"
View Source
const CsvTag = "l_csv"

Variables

View Source
var ErrEmptyArray = errors.New("empty values")
View Source
var ErrNotArray = errors.New("not values")
View Source
var ErrValNotStruct = errors.New("value not struct")
View Source
var ErrValsNotSlicePointer = errors.New("values must be a pointer to a slice")

Functions

func ConvertFloatTo2Decimal

func ConvertFloatTo2Decimal(data reflect.Value, fieldName string, value reflect.Value, others interface{}) reflect.Value

func ConvertTimeToString

func ConvertTimeToString(data reflect.Value, fieldName string, value reflect.Value, others interface{}) reflect.Value

func CsvToStructs

func CsvToStructs(data [][]string, values reflect.Value) error

func GetDefaultConverterMap

func GetDefaultConverterMap(exportTimeZone int64) map[string]*CsvConverter

func StructsToCsv

func StructsToCsv(
	writer *csv.Writer,
	values reflect.Value,
	csvSetting CsvSetting,
) (err error)

Types

type CsvConverter

type CsvConverter struct {
	ConvertFunc func(structVal reflect.Value, fieldName string, fieldVal reflect.Value, converterParams interface{}) reflect.Value
	Value       interface{}
}

type CsvSetting

type CsvSetting struct {
	RequireHeader bool
	IgnoreFields  []string
	Converters    map[string]*CsvConverter
}

Jump to

Keyboard shortcuts

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