Documentation ¶
Index ¶
- Constants
- Variables
- func AsMap[T any, K comparable](slice []T, keyGetter Mapper[T, K]) map[K]T
- func AsSet[T any, K comparable](slice []T, keyGetter Mapper[T, K]) map[K]bool
- func ByteCountSI(b int64) string
- func Chunk[T any](slice []T, size int) [][]T
- func Copy[T any](t T) T
- func DebugPrintJson(x ...interface{})
- func DebugPrintYaml(x interface{})
- func Distinct[T comparable](data []T) []T
- func Exists[T any](slice []T, finder Predicate[T]) bool
- func FilterSlice[T any](slice []T, predicate Predicate[T]) []T
- func GroupByProperty[T any, K comparable](items []T, getProperty func(T) K) map[K][]T
- func Keys[K comparable, V any](m map[K]V) []K
- func LogSymbol(coin, altCoin string) string
- func Map[T, V any](slice []T, mapper Mapper[T, V]) []V
- func Symbol(coin, altCoin string) string
- func ToASCIITable[T any](data []T, headers []string, footer []string, columns func(T) []string, ...) string
- func ToJSON(x interface{}) string
- func ToYAML(x interface{}) string
- func Unsymbol(symbol string, referentialCoins, altCoins []string) (string, string, error)
- func Values[K comparable, V any](m map[K]V) []V
- func WrapPtr[T any](t T) *T
- type ASCIITableOption
- type Mapper
- type Predicate
Constants ¶
View Source
const Day time.Duration = 24 * time.Hour
Variables ¶
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
func AsMap ¶
func AsMap[T any, K comparable](slice []T, keyGetter Mapper[T, K]) map[K]T
func ByteCountSI ¶
func Chunk ¶
Chunk batches []T into [][]T in groups of size. The final chunk of []T will be smaller than size if the input slice cannot be chunked evenly. It does not make any copies of slice elements.
As an example, take a slice of 5 integers and create chunks of 2 integers each (the final value creates a short chunk):
slices.Chunk([]int{1, 2, 3, 4, 5}, 2) = [][]int{{1, 2}, {3, 4}, {5}}
func DebugPrintJson ¶
func DebugPrintJson(x ...interface{})
func DebugPrintYaml ¶
func DebugPrintYaml(x interface{})
func Distinct ¶
func Distinct[T comparable](data []T) []T
func FilterSlice ¶
func FilterSlice[T any](slice []T, predicate Predicate[T]) []T
func GroupByProperty ¶
func GroupByProperty[T any, K comparable](items []T, getProperty func(T) K) map[K][]T
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
func ToASCIITable ¶
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
Types ¶
type ASCIITableOption ¶
type ASCIITableOption func(*tablewriter.Table)
Click to show internal directories.
Click to hide internal directories.