Documentation
¶
Index ¶
- Constants
- func BuildTree[T TreeNode](nodes []T, sortField string) []T
- func CompareInt(a, b int) int
- func CompareString(a, b string) int
- func CompareValues(a, b any) int
- type AnyArray
- type Criterion
- type DynamicSorter
- type JSON
- type JSONArray
- type JSONData
- type MultiCriteria
- type Order
- type SelectOption
- type Sortable
- type StringArray
- type Struct
- type TreeNode
Constants ¶
const ( ExtWindows = ".dll" ExtDarwin = ".dylib" ExtLinux = ".so" )
Platform-specific extensions
const ( PlatformWindows = "windows" PlatformDarwin = "darwin" PlatformLinux = "linux" )
Platform-specific names
Variables ¶
This section is empty.
Functions ¶
func CompareInt ¶ added in v0.1.2
CompareInt compares two integers. Returns -1 if a < b. Returns 1 if a > b. Returns 0 if a == b.
func CompareString ¶ added in v0.1.2
CompareString compares two strings lexicographically. Returns -1 if a < b. Returns 1 if a > b. Returns 0 if a == b.
func CompareValues ¶ added in v0.1.2
CompareValues compares two values and returns -1, 0, or 1. Supports int and string types. Returns -1 if a < b. Returns 1 if a > b. Returns 0 if a == b or types are not comparable.
Types ¶
type AnyArray ¶
type AnyArray = []any
AnyArray represents a slice of any type, useful for generic lists.
type Criterion ¶
type Criterion struct {
Field string `json:"field"` // Field to sort by
Order Order `json:"order"` // Sort direction
}
Criterion represents a single sorting criterion.
type DynamicSorter ¶
type DynamicSorter struct {
Data []map[string]any // Dataset to be sorted
Getter func(item map[string]any, field string) (any, error) // Field value getter
}
DynamicSorter provides a generic implementation for sorting based on criteria.
func (*DynamicSorter) Sort ¶
func (ds *DynamicSorter) Sort(criteria MultiCriteria) error
Sort sorts the dataset based on the given MultiCriteria.
type JSONData ¶
type JSONData struct {
Data JSON `json:"data,omitempty"`
}
JSONData provides utility methods for working with JSON objects.
type MultiCriteria ¶
type MultiCriteria struct {
Criteria []Criterion `json:"criteria"` // List of sorting criteria
}
MultiCriteria supports multi-field sorting.
type SelectOption ¶ added in v0.1.2
type SelectOption struct {
Label string `json:"label"`
Value string `json:"value"`
Icon string `json:"icon"`
}
SelectOption represents a select option
type Sortable ¶
type Sortable interface {
Sort(criteria MultiCriteria) error // Sort method to be implemented
}
Sortable represents a sortable dataset interface.
type StringArray ¶
type StringArray = []string
StringArray represents a slice of strings, typically used for lists of string data.