Documentation ¶
Index ¶
- func AssertEqual(t *testing.T, except, actual interface{}, msg string)
- func AssertEqualJson(t *testing.T, except, actual string)
- func AssertEqualString(t *testing.T, except, actual, msg string)
- func Bytes2str(b *[]byte) string
- func CloneMap[T1 comparable, T2 any](m map[T1]T2) map[T1]T2
- func Copy[T any](arr []T) []T
- func Download(url, dist string) error
- func FileExist(file string) bool
- func FlattenMap(m map[string]interface{}) map[string]interface{}
- func GetByPath(obj map[string]interface{}, path []string) interface{}
- func Includes[T comparable](arr []T, v T) bool
- func IsDir(file string) bool
- func IsFile(file string) bool
- func IsNilPtr(v interface{}) bool
- func JsonToKeyPathAndVal(jsonStr string) (map[string]interface{}, error)
- func Keys[K comparable, V any](m map[K]V) []K
- func Merge[T1 comparable, T2 any](src, stuff map[T1]T2)
- func MergeMap(dst map[string]interface{}, src map[string]interface{})
- func MergeMaps(dst map[string]interface{}, src ...map[string]interface{})
- func PickOne[T1 comparable, T2 any](sets map[T1]T2) (v T2)
- func PickOnePair[T1 comparable, T2 any](sets map[T1]T2) (k T1, v T2)
- func RemoveAt[T any](arr *[]T, i int)
- func RemoveJsonComments(str string) ([]byte, error)
- func Shell(command string, args ...string)
- func ShellInDir(dir, command string, args ...string)
- func Str2bytes(s string) []byte
- func Swap[T any](arr []T, i, j int)
- func TakeOne[T1 comparable, T2 any](sets map[T1]T2) (v T2)
- func UnTarGz(tarball, dist string) error
- func WalkObj(obj interface{}, path []string, cb WalkObjFn, key interface{}, ...) bool
- type DirWalker
- type DirWalkerHandle
- type KvPair
- type LruCache
- type OrderedMap
- type WalkObjFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
func AssertEqualJson ¶
func AssertEqualString ¶
func Bytes2str ¶ added in v0.0.10
cast `[]byte` to string by zero-copy, caller should to ensure the `b` will NOT be changed in the subsequent processes refer: https://github.com/golang/go/blob/a6219737e3eb062282e6483a915c395affb30c69/src/strings/builder.go#L48
func CloneMap ¶
func CloneMap[T1 comparable, T2 any](m map[T1]T2) map[T1]T2
func FlattenMap ¶
func Includes ¶
func Includes[T comparable](arr []T, v T) bool
func JsonToKeyPathAndVal ¶
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
func Merge ¶
func Merge[T1 comparable, T2 any](src, stuff map[T1]T2)
func PickOne ¶
func PickOne[T1 comparable, T2 any](sets map[T1]T2) (v T2)
func PickOnePair ¶
func PickOnePair[T1 comparable, T2 any](sets map[T1]T2) (k T1, v T2)
func RemoveAt ¶
move the targe elem to the tail of the slice then do the pop so this method will change the order of the origin slide
func RemoveJsonComments ¶
remove comments in json, for keeping the loc of error is meaningful, the comments are replaced with their equal-length spaces
func ShellInDir ¶
func TakeOne ¶
func TakeOne[T1 comparable, T2 any](sets map[T1]T2) (v T2)
Types ¶
type DirWalker ¶
by the benchmark, there is no execution performance benefit from the works pool, however the works pool is still useful since it can stop the routine more precisely
func NewDirWalker ¶
func NewDirWalker(dir string, concurrent int, handle DirWalkerHandle) *DirWalker
type DirWalkerHandle ¶
type KvPair ¶
type KvPair[K comparable, V any] struct { Key K Val V }
type LruCache ¶
type LruCache[K comparable, V any] struct { // contains filtered or unexported fields }
func NewLruCache ¶
func NewLruCache[K comparable, V any](cap int, clear int) *LruCache[K, V]
- cap, the capacity of the store, normally the max number elements can be stored - clear, the number of elements to be cleared when the store is full, default is 1/3 of capacity
type OrderedMap ¶
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
func NewOrderedMap ¶
func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V]
func (*OrderedMap[k, v]) Front ¶
func (o *OrderedMap[k, v]) Front() *list.Element
func (*OrderedMap[K, V]) Get ¶
func (o *OrderedMap[K, V]) Get(key K) (v V)
func (*OrderedMap[K, V]) HasKey ¶
func (o *OrderedMap[K, V]) HasKey(key K) bool
func (*OrderedMap[k, v]) Remove ¶
func (o *OrderedMap[k, v]) Remove(key k)
func (*OrderedMap[K, V]) Set ¶
func (o *OrderedMap[K, V]) Set(key K, val V) *list.Element