Documentation ¶
Overview ¶
Package drow provides a dynamic struct/row type.
Index ¶
- func XToStruct(r Row) any
- type Field
- func (f Field) Float32() float32
- func (f Field) Float64() float64
- func (f Field) Int() int
- func (f Field) Int16() int16
- func (f Field) Int32() int32
- func (f Field) Int64() int64
- func (f Field) String() string
- func (f Field) Uint() uint
- func (f Field) Uint16() uint16
- func (f Field) Uint32() uint32
- func (f Field) Uint64() uint64
- type FieldExpr
- type IntOrString
- type Row
- func (r Row) At(s IntOrString) Field
- func (r Row) Columns() []string
- func (r Row) Concat(r2 Row) Row
- func (r Row) Drop(names ...string) Row
- func (r Row) Eq(v any) bool
- func (r Row) Flat() Row
- func (r Row) Has(s string) bool
- func (r Row) Index(s string) int
- func (r Row) Info() string
- func (r Row) InfoTree() string
- func (r Row) MarshalJSON() ([]byte, error)
- func (r Row) Merge(r2 Row) Row
- func (r Row) Prefix(prefix string) Row
- func (r Row) Rename(old, name string) Row
- func (r Row) RenameFields(m map[string]string) Row
- func (r Row) Select(cols ...IntOrString) Row
- func (r Row) String() string
- func (r Row) ToMap() map[string]any
- func (r *Row) UnmarshalJSON(data []byte) error
- func (r Row) Value(s IntOrString) any
- func (r Row) Values() []any
- func (r Row) WithField(s string, v any) Row
- func (r Row) WithFields(fs ...Field) Row
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Field ¶
Field is a single field in a row
func (Field) Float32 ¶
Float32 returns the float32 representation of the field or zero if it can't be converted
func (Field) Float64 ¶
Float64 returns the float64 representation of the field or zero if it can't be converted
func (Field) Int16 ¶
Int16 returns the int16 representation of the field or zero if it can't be converted
func (Field) Int32 ¶
Int32 returns the int32 representation of the field or zero if it can't be converted
func (Field) Int64 ¶
Int64 returns the int64 representation of the field or zero if it can't be converted
func (Field) Uint ¶
Uint returns the uint representation of the field or zero if it can't be converted
func (Field) Uint16 ¶
Uint16 returns the int16 representation of the field or zero if it can't be converted
type IntOrString ¶
type IntOrString any
type Row ¶
type Row []Field
Row is a slice of fields with a defined sequence.
func FromMap ¶
FromMap creates a row from a map[string]interface{} the fields might not be in the same order as the map
func FromStruct ¶
func (Row) Concat ¶
Concat returns a new row with the fields of r and the fields of r2. this might duplicate field names.
func (Row) MarshalJSON ¶
func (Row) RenameFields ¶
RenameFields renames multiple fields based on map
func (Row) Select ¶
func (r Row) Select(cols ...IntOrString) Row
Select returns a new row with the named selected fields.
func (*Row) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (Row) WithFields ¶
WithFields returns a copy of the row with the several fields if the field name exists the value will be replaced in the new row.