tools

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopySlice

func CopySlice[T any](src []T) []T

func IF added in v0.0.2

func IF[T any](condition bool, trueValue T, falseValue T) T

func JsonPrettyString added in v0.0.5

func JsonPrettyString(m any) (string, error)

func JsonString

func JsonString(m any) (string, error)

func MustJsonPrettyString added in v0.0.5

func MustJsonPrettyString(m any) string

func MustJsonString added in v0.0.5

func MustJsonString(m any) string

func SsToTs

func SsToTs[S, T any](transmitter func(S) T, ss ...S) []T

func TsToSs

func TsToSs[T, S any](transmitter func(T) (S, bool), ts ...T) []S

Types

type JSON

type JSON json.RawMessage

func (*JSON) Bytes

func (j *JSON) Bytes() []byte

func (*JSON) Clone

func (j *JSON) Clone() JSON

func (*JSON) Equal

func (j *JSON) Equal(o *JSON) bool

func (JSON) Format

func (j JSON) Format(f fmt.State, c rune)

func (JSON) IsNull

func (j JSON) IsNull() bool

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

func (*JSON) Scan

func (j *JSON) Scan(value interface{}) error

func (*JSON) String

func (j *JSON) String() string

func (*JSON) UnmarshalJSON

func (j *JSON) UnmarshalJSON(data []byte) error

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

type JSONBuilder

type JSONBuilder struct{}

func (JSONBuilder) FromObj

func (b JSONBuilder) FromObj(obj any) (JSON, error)

func (JSONBuilder) FromString

func (b JSONBuilder) FromString(jsonStr string) (JSON, error)

func (JSONBuilder) NoErrObj

func (b JSONBuilder) NoErrObj(obj any) JSON

func (JSONBuilder) NoErrString

func (b JSONBuilder) NoErrString(jsonStr string) JSON

type KKMap

type KKMap[K1 comparable, K2 comparable, V any] map[K1]map[K2]V

func (KKMap[K1, K2, V]) Delete

func (kkm KKMap[K1, K2, V]) Delete(k1 K1, k2 K2)

func (KKMap[K1, K2, V]) DeleteKey

func (kkm KKMap[K1, K2, V]) DeleteKey(k1 K1)

func (KKMap[K1, K2, V]) Get

func (kkm KKMap[K1, K2, V]) Get(k1 K1, k2 K2) (v V, exist bool)

func (KKMap[K1, K2, V]) IsExist added in v0.0.4

func (kkm KKMap[K1, K2, V]) IsExist(k1 K1, k2 K2) (exist bool)

func (KKMap[K1, K2, V]) IsExistKey added in v0.0.5

func (kkm KKMap[K1, K2, V]) IsExistKey(k1 K1) (exist bool)

func (KKMap[K1, K2, V]) Put

func (kkm KKMap[K1, K2, V]) Put(k1 K1, k2 K2, v V) KKMap[K1, K2, V]

func (KKMap[K1, K2, V]) PutKey added in v0.0.4

func (kkm KKMap[K1, K2, V]) PutKey(k1 K1, km2 map[K2]V) KKMap[K1, K2, V]

func (KKMap[K1, K2, V]) Range added in v0.0.3

func (kkm KKMap[K1, K2, V]) Range(handler func(k1 K1, k2 K2, v V) (goon bool))

type KMap

type KMap[K comparable, V any] map[K]V

func (KMap[K, V]) Delete

func (km KMap[K, V]) Delete(ks ...K)

func (KMap[K, V]) ExistingList added in v0.0.5

func (km KMap[K, V]) ExistingList(keys ...K) []V

func (KMap[K, V]) Get

func (km KMap[K, V]) Get(k K) (v V, exist bool)

func (KMap[K, V]) IsExist

func (km KMap[K, V]) IsExist(key K) bool

func (KMap[K, V]) Keys

func (km KMap[K, V]) Keys(filters ...func(k K, v V) bool) []K

func (KMap[K, V]) List

func (km KMap[K, V]) List(keys ...K) []V

func (KMap[K, V]) Map

func (km KMap[K, V]) Map() map[K]V

func (KMap[K, V]) Merge

func (km KMap[K, V]) Merge(kmo KMap[K, V]) KMap[K, V]

func (KMap[K, V]) Put

func (km KMap[K, V]) Put(key K, value V) KMap[K, V]

func (KMap[K, V]) SubMap added in v0.0.4

func (km KMap[K, V]) SubMap(ks ...K) KMap[K, V]

SubMap generate a new map with all keys from ks, even if there's no corresponding value in km.

func (KMap[K, V]) Values

func (km KMap[K, V]) Values(filters ...func(k K, v V) bool) []V

type KS

type KS[K comparable] []K

func (KS[K]) Append added in v0.0.5

func (ks KS[K]) Append(k K) KS[K]

func (KS[K]) Clone

func (ks KS[K]) Clone() KS[K]

func (KS[K]) Contains

func (ks KS[K]) Contains(tgt K) bool

func (KS[K]) Dedup

func (ks KS[K]) Dedup(validators ...func(k K) bool) KS[K]

func (KS[K]) DedupRange

func (ks KS[K]) DedupRange(one func(k K) error) error

func (KS[K]) Equal added in v0.0.5

func (ks KS[K]) Equal(os KS[K]) bool

func (KS[K]) IterateRemove

func (ks KS[K]) IterateRemove(tgt K) KS[K]

func (KS[K]) Map

func (ks KS[K]) Map() KSet[K]

func (KS[K]) Remove

func (ks KS[K]) Remove(tgts ...K) KS[K]

func (KS[K]) Slice

func (ks KS[K]) Slice() []K

func (KS[K]) Sub added in v0.0.5

func (ks KS[K]) Sub(offset, limit int) KS[K]

type KSet

type KSet[K comparable] map[K]struct{}

func (KSet[K]) Add

func (km KSet[K]) Add(ks ...K) KSet[K]

func (KSet[K]) Append

func (km KSet[K]) Append(ks ...K) KSet[K]

func (KSet[K]) AppendSet

func (km KSet[K]) AppendSet(s KSet[K]) KSet[K]

func (KSet[K]) CAS

func (km KSet[K]) CAS(k K) (set KSet[K], changed bool)

func (KSet[K]) Clone

func (km KSet[K]) Clone() KSet[K]

func (KSet[K]) Delete

func (km KSet[K]) Delete(ks ...K) KSet[K]

func (KSet[K]) Equal

func (km KSet[K]) Equal(o KSet[K]) bool

func (KSet[K]) ExsitingList added in v0.0.5

func (km KSet[K]) ExsitingList(ks ...K) []K

func (KSet[K]) IsExist

func (km KSet[K]) IsExist(k K) bool

func (KSet[K]) Slice

func (km KSet[K]) Slice(emptyNil ...bool) []K

type KV

type KV[K comparable, V any] struct{}

func (KV[K, V]) KeyNotInMap

func (KV[K, V]) KeyNotInMap(m map[K]V, ks ...K) []K

func (KV[K, V]) List

func (KV[K, V]) List(keys []K, valuesMap map[K]V) []V

func (KV[K, V]) MapKeys

func (KV[K, V]) MapKeys(m map[K]V) []K

func (KV[K, V]) MapValues

func (KV[K, V]) MapValues(m map[K]V) []V

func (KV[K, V]) OneOfMap

func (KV[K, V]) OneOfMap(k K, mapper func([]K) (map[K]V, error)) (v V, err error)

func (KV[K, V]) PutToMap

func (KV[K, V]) PutToMap(m map[K]V, k K, v V) map[K]V

func (KV[K, V]) RangeByK

func (KV[K, V]) RangeByK(ks []K, m map[K]V, dowork func(k K, v V) error) error

type NotNullJSON

type NotNullJSON JSON

func (*NotNullJSON) Bytes

func (n *NotNullJSON) Bytes() []byte

func (*NotNullJSON) Clone

func (n *NotNullJSON) Clone() NotNullJSON

func (*NotNullJSON) Equal

func (n *NotNullJSON) Equal(o *NotNullJSON) bool

func (NotNullJSON) IsNull

func (n NotNullJSON) IsNull() bool

func (NotNullJSON) MarshalJSON

func (n NotNullJSON) MarshalJSON() ([]byte, error)

func (*NotNullJSON) Scan

func (n *NotNullJSON) Scan(value interface{}) error

func (*NotNullJSON) String

func (n *NotNullJSON) String() string

func (NotNullJSON) ToJSON added in v0.0.5

func (n NotNullJSON) ToJSON() JSON

func (*NotNullJSON) UnmarshalJSON

func (n *NotNullJSON) UnmarshalJSON(data []byte) error

func (NotNullJSON) Value

func (n NotNullJSON) Value() (driver.Value, error)

type SS

type SS []string

func (SS) Append

func (ss SS) Append(s ...string) SS

func (SS) Clone

func (ss SS) Clone() SS

func (SS) Dedup

func (ss SS) Dedup(transfers ...func(input string) (string, bool)) SS

func (SS) Has added in v0.0.5

func (ss SS) Has(s string) bool

func (SS) Join

func (ss SS) Join(sep string) string

Join strings seperated by sep, ignoreing empty strings

func (SS) Map

func (ss SS) Map() KSet[string]

func (SS) Matchs added in v0.0.5

func (ss SS) Matchs(str string) bool

Matchs if any s in ss contained by str

func (SS) Remove

func (ss SS) Remove(strs ...string) SS

func (SS) Slice

func (ss SS) Slice() []string

func (SS) Sort added in v0.0.5

func (ss SS) Sort() SS

Jump to

Keyboard shortcuts

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