types

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ExtWindows = ".dll"
	ExtDarwin  = ".dylib"
	ExtLinux   = ".so"
)

Platform-specific extensions

View Source
const (
	PlatformWindows = "windows"
	PlatformDarwin  = "darwin"
	PlatformLinux   = "linux"
)

Platform-specific names

Variables

This section is empty.

Functions

func BuildTree

func BuildTree[T TreeNode](nodes []T, sortField string) []T

BuildTree builds a tree structure from the given nodes.

func CompareInt

func CompareInt(a, b int) int

CompareInt compares two integers. Returns -1 if a < b. Returns 1 if a > b. Returns 0 if a == b.

func CompareString

func CompareString(a, b string) int

CompareString compares two strings lexicographically. Returns -1 if a < b. Returns 1 if a > b. Returns 0 if a == b.

func CompareValues

func CompareValues(a, b any) int

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 JSON

type JSON = map[string]any

JSON represents a generic JSON object, useful for handling dynamic key-value pairs.

type JSONArray

type JSONArray = []JSON

JSONArray represents an array of JSON objects.

type JSONData

type JSONData struct {
	Data JSON `json:"data,omitempty"`
}

JSONData provides utility methods for working with JSON objects.

func (*JSONData) FromBytes

func (j *JSONData) FromBytes(data []byte) error

FromBytes deserializes a byte slice into JSONData.

func (*JSONData) ToBytes

func (j *JSONData) ToBytes() ([]byte, error)

ToBytes serializes JSONData to a byte slice.

type MultiCriteria

type MultiCriteria struct {
	Criteria []Criterion `json:"criteria"` // List of sorting criteria
}

MultiCriteria supports multi-field sorting.

type Order

type Order string

Order represents sorting direction.

const (
	Ascending  Order = "asc"  // Ascending order
	Descending Order = "desc" // Descending order
)

type SelectOption

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.

type Struct

type Struct struct{}

Struct represents an empty struct, often used for signals or stateless markers.

type TreeNode

type TreeNode interface {
	GetID() string
	GetParentID() string
	SetChildren([]TreeNode)
	GetChildren() []TreeNode
	GetSortValue(field string) any
}

TreeNode represents a tree node.

Jump to

Keyboard shortcuts

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