types

package
v0.5.15 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 4 Imported by: 39

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RowToMap added in v0.3.0

func RowToMap(om Row) map[string]interface{}

RowToMap converts a Row to a standard Go map with string keys. The keys lose their original order.

Types

type FieldName

type FieldName = string

func GetFields added in v0.3.0

func GetFields(om Row) []FieldName

GetFields retrieves a list of field names (keys) from the provided Row, in their original order.

type GenericCellValue

type GenericCellValue = interface{}

type MapRowPair added in v0.3.0

func MRP added in v0.3.0

func MRP(key FieldName, value GenericCellValue) MapRowPair

MRP creates a new MapRowPair with the given key and value. This is useful when creating a Row with NewRow.

type Row

func NewRow added in v0.3.0

func NewRow(initialData ...MapRowPair) Row

NewRow creates a new Row instance with the given initial data pairs. The order of the pairs is preserved.

func NewRowFromMap added in v0.3.0

func NewRowFromMap(hash map[FieldName]GenericCellValue) Row

NewRowFromMap creates a new Row instance populated with the contents of the provided map. The fields in the resulting Row are sorted alphabetically.

func NewRowFromMapWithColumns added in v0.3.0

func NewRowFromMapWithColumns(hash map[FieldName]GenericCellValue, columns []FieldName) Row

NewRowFromMapWithColumns creates a new Row instance with values from the provided map, but only for the columns specified. If a column doesn't exist in the map, it is skipped.

func NewRowFromRow added in v0.4.13

func NewRowFromRow(row Row) Row

NewRowFromRow creates a new Row instance with a deep copy of the contents from the provided row.

func NewRowFromStruct added in v0.3.0

func NewRowFromStruct(i interface{}, lowerCaseKeys bool) Row

NewRowFromStruct creates a new Row instance populated with the field values from the provided struct. The field names of the struct become the keys in the Row. If lowerCaseKeys is true, the field names are converted to lowercase.

func SetFromStruct added in v0.4.0

func SetFromStruct(row Row, i interface{}, lowerCaseKeys bool) Row

SetFromStruct populates the provided row with values from the given struct. The field names of the struct become the keys in the Row. If lowerCaseKeys is true, the field names are converted to lowercase. Returns the populated row.

type Table

type Table struct {
	Columns []FieldName
	Rows    []Row
	// contains filtered or unexported fields
}

func NewTable

func NewTable() *Table

func (*Table) AddRows added in v0.3.0

func (t *Table) AddRows(rows ...Row)

func (*Table) SetColumnOrder added in v0.3.0

func (t *Table) SetColumnOrder(columns []FieldName)

SetColumnOrder will set the given columns to be the first one to be output. Other columns already present in the order will be appended at the end, preserving the original order.

type TableName

type TableName = string

Jump to

Keyboard shortcuts

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