rock

package
v2.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package rock generic based common package processing

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractArrUnique

func ExtractArrUnique[T constraints.ValueIterable](count int, arr []T) []T

ExtractArrUnique extracting array elements with loss (non-repeatable) from an array

func FormatKv

func FormatKv[K constraints.KeyIterable, V any](data map[K]V) string

FormatKv @todo neet to test

Example
s := FormatKv(map[string]any{
	"name":    "Joshua Conero",
	"meeting": 20.1,
})
fmt.Println("列表输出如下:\n" + s)
Output:

name       Joshua Conero
meeting    20.1

func FormatList

func FormatList[V any](vList []V, joins ...string) string
Example
s := FormatList([]string{"1", "this\\'s test", "box", "a", "must", "base", "念奴娇", "√√√√√", "", "saw", "no-list", "box",
	"box", "box", "box", "box", "box", "box", "box", "box", "box", "box", "box", "box", "box"})
fmt.Println("列表输出如下:\n" + s)
Output:

func FormatTable

func FormatTable[V any](table [][]V, seps ...int) string

FormatTable two-dimensional array formatted output

func InList

func InList[T constraints.Equable](list []T, value T) bool

InList determines whether a key value exists in the list

func ListAny

func ListAny[T constraints.KeyIterable](vList []T) []any

ListAny data slice convert to any slice

func ListEq

func ListEq[T constraints.Equable](list []T, compare []T) bool

ListEq Determines whether an array is equal

func ListGetOr

func ListGetOr[T any](list []T, index int, def T) T

ListGetOr Read element values through index or use default substitution (when not present)

func ListIndex

func ListIndex[T constraints.Equable](list []T, value T) (index int)

ListIndex get index by search value from list

func ListNoRepeat

func ListNoRepeat[T constraints.Equable](list []T) []T

ListNoRepeat filter duplicate elements in list

func ListRemove

func ListRemove[T constraints.Equable](list []T, removes ...T) []T

ListRemove removes the specified element from the list

func ListSubset

func ListSubset[T constraints.Equable](list []T, subset []T) bool

ListSubset determine whether the given subarray is accurate

func MapAssign

func MapAssign[K constraints.KeyIterable, V any](source map[K]V, more ...map[K]V) map[K]V

MapAssign Merge multiple map parameters, where the same key value is the forward overwrite value.

And never return nil.

func MapFilter

func MapFilter[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V

MapFilter use the keys of map to filter itself

func MapGenByKv

func MapGenByKv[K constraints.KeyIterable, V constraints.ValueIterable](keys []K, values []V) (kv map[K]V)

MapGenByKv Create dictionary by key value pair array combination

func MapKeys

func MapKeys[T constraints.KeyIterable, X constraints.ValueIterable](vMap map[T]X) (keys []T)

MapKeys Extract the key name array of the dictionary

func MapKeysString

func MapKeysString[K constraints.KeyIterable, V any](data map[K]V) []string

func MapSlice

func MapSlice[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V

MapSlice use the keys of map to slice itself

func MapValues

func MapValues[T constraints.KeyIterable, X constraints.KeyIterable](vMap map[T]X) (values []X)

MapValues Extract the values name array of the dictionary

func Param

func Param[T any](defValue T, args ...T) T

Param Extract indefinite parameters from functions and default code values

func ParamFunc

func ParamFunc[T any](defFunc func() T, args ...T) T

ParamFunc Implementing parameter extraction through custom callback functions

func ParamIndex

func ParamIndex[T any](index int, defValue T, args ...T) T

ParamIndex Gets parameters from the list according to the index, the index value starts with 1

Types

This section is empty.

Directories

Path Synopsis
Package constraints The stereotype extension type definition is used for function /type annotations
Package constraints The stereotype extension type definition is used for function /type annotations

Jump to

Keyboard shortcuts

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