hadata

package
v0.2.73 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any added in v0.2.58

func Any[T any](data []T, check func(d T) bool) bool

func CaseCamelToSnake added in v0.2.28

func CaseCamelToSnake(str string) string

func CheckInterfaceDataIsSlice added in v0.2.11

func CheckInterfaceDataIsSlice(x any) (bool, any)

func CheckIsPointer added in v0.2.15

func CheckIsPointer(data any) bool

func ClearPointer added in v0.2.4

func ClearPointer(data any) any

func Combine added in v0.2.36

func Combine[T any, Q any](data []T, target Q, combine func(T, Q) T) []T

func EmptyThen added in v0.1.32

func EmptyThen(v1 string, v2 string) string

if v1 is empty, then v2

func Every added in v0.2.58

func Every[T any](data []T, check func(d T) bool) bool

func FindTagFiled added in v0.2.13

func FindTagFiled[T any](tag string, mark string) []string

return field in json tag name

func FindTypeFiled added in v0.2.13

func FindTypeFiled[T any, V any]() []string

return field in json tag name

func FloatCompare added in v0.2.27

func FloatCompare(f1 float64, f2 float64, precision int) int
data return

-1: f1<f2 0: f1=f2 1:f1>f2

func Fold added in v0.2.57

func Fold[V any, T any](data []T, initValue V, fold func(v V, d T) V) V

func GenerateRandomString added in v0.1.37

func GenerateRandomString(n int) string

func GenerateRandomStringFromGivenRune added in v0.1.39

func GenerateRandomStringFromGivenRune(r []rune, n int) string

func GetDataFromJson added in v0.2.13

func GetDataFromJson[T any](m string) (T, error)

func GetDataFromMap added in v0.2.13

func GetDataFromMap[T any](m any) (T, error)

func GetFiledTagSlice added in v0.2.16

func GetFiledTagSlice(f reflect.StructField, tag string) []string

func GetFloatFromString added in v0.1.5

func GetFloatFromString(d string) (float64, error)

func GetInt64FromString added in v0.2.51

func GetInt64FromString(s string) (int64, error)

func GetIntFromString added in v0.1.10

func GetIntFromString(s string) (int, error)

func GetJsonFieldName added in v0.2.16

func GetJsonFieldName(f reflect.StructField) (name string, omitempty bool)

func GetManyRandomNumber added in v0.2.21

func GetManyRandomNumber(min int, max int, count int) []int

return random int between min and max, not include max

func GetMapKey added in v0.2.54

func GetMapKey[T any](m map[string]T) []string

func GetPointerData added in v0.2.0

func GetPointerData(data any) (any, error)

func GetRandomNumber added in v0.2.21

func GetRandomNumber(min int, max int) int

return random int between min and max, not include max

func GetSliceFromInterface added in v0.2.11

func GetSliceFromInterface(x any) ([]any, error)

func GetStringFromFloat added in v0.1.25

func GetStringFromFloat[T FloatData](f T) string

func GetStringFromInt added in v0.1.4

func GetStringFromInt(d int) string

get string from int

func GetStringFromInterface added in v0.1.24

func GetStringFromInterface(x any) string

func GetStringMap added in v0.2.23

func GetStringMap(data map[string]any) (map[string]string, error)

transfer 'any' value to string or json if not string

func GetStructName added in v0.1.44

func GetStructName(data any) string

func GetStructNameInFirstLetterLowerCase added in v0.2.59

func GetStructNameInFirstLetterLowerCase(data any) string

func GetStructNameInLowerCase added in v0.1.44

func GetStructNameInLowerCase(data any) string

func GetVersionData added in v0.2.65

func GetVersionData(version string) (head string, body string)

func InterSlice added in v0.2.13

func InterSlice[T comparable](s1 []T, s2 []T) []T

func IsInSlice added in v0.2.12

func IsInSlice[T comparable](list []T, data T) bool

check is data is in list

func LookUpFirstTagMark added in v0.2.5

func LookUpFirstTagMark(data any, tag string, mark string) (name string, value any, err error)

func Map added in v0.2.32

func Map[T any, Q any](data []T, trans func(T) Q) []Q

func MapFromSlice added in v0.2.31

func MapFromSlice[T any](data []T, getKey func(T) string) map[string]T

func MapToStruct

func MapToStruct(input any, output any) error

func Maps added in v0.2.52

func Maps[T any, Q any, R any](data []T, trans func(T) (Q, R)) ([]Q, []R)

func Max added in v0.2.60

func Max[T constraints.Ordered](x, y T) T

func ReadStructTagData added in v0.2.4

func ReadStructTagData(data any, tag string, includingField ...string) (map[string]any, error)

return struct tag data, in json key, empty field will be dropped unless specified in including field

func RemElement added in v0.2.42

func RemElement[T any](data []T, index int) []T

func RemElementX added in v0.2.42

func RemElementX[T any](data []T, index int) []T

remove specific element by replace it with the last element, it's faster, but order changed

func RemWhere added in v0.2.53

func RemWhere[T any](data []T, where func(T) bool) []T

func RemWhereX added in v0.2.53

func RemWhereX[T any](data []T, where func(T) bool) []T

remove element by replace it with the last elements, it's faster, but order will be changed

use this function if you don't care about the original order

func RuneLen added in v0.2.30

func RuneLen(str string) int

func SnakeToCaseCamel added in v0.2.73

func SnakeToCaseCamel(str string, isTitle bool) string

func SplitStringOnUpperCase added in v0.2.28

func SplitStringOnUpperCase(str string) []string

func StructToMap

func StructToMap(item any) map[string]any

func StructToStringMap

func StructToStringMap(item any) map[string]string

func SubMaxLen added in v0.2.63

func SubMaxLen[T any](list []T, length int) []T

func SwapSlice added in v0.2.12

func SwapSlice[T any](ds *[]T) error

swap slice

func TitleWord added in v0.2.48

func TitleWord(word string) string

func Transform added in v0.2.33

func Transform[T any, Q any](data []T, trans func(T) []Q) []Q

func Unique

func Unique[T comparable](strSlice []T) []T

func UpgradeVersion added in v0.0.18

func UpgradeVersion(version string, place int) (string, error)
upgrade version

place start from 1

can be used in version like 1.0.1 or v1.0

func VersionCleaner added in v0.1.31

func VersionCleaner(v string) string

rm v/V from head

func VersionToInt added in v0.1.29

func VersionToInt(v string, blockLength int) (int, error)

transfer version to int

Types

type Adder added in v0.2.23

type Adder struct {
	Step int
	Min  int
	Max  int
}

func NewAdder added in v0.2.23

func NewAdder(min int, max int, step int) *Adder

func (*Adder) Add added in v0.2.23

func (adder *Adder) Add(base int) int

type Binder added in v0.1.33

type Binder string

func (Binder) With added in v0.1.33

func (b Binder) With(t ...string) string

type FloatData added in v0.2.12

type FloatData interface {
	float32 | float64
}

type Sort added in v0.2.1

type Sort interface {
	GetValue() int
}

func QuickSort added in v0.2.1

func QuickSort(arr []Sort, low, high int) []Sort

type StringBinder added in v0.1.18

type StringBinder struct {
	Builder strings.Builder
}

func NewStringBinder added in v0.1.18

func NewStringBinder() *StringBinder

func (*StringBinder) BindInt added in v0.1.18

func (binder *StringBinder) BindInt(num ...int) *StringBinder

func (*StringBinder) BindString added in v0.1.18

func (binder *StringBinder) BindString(str ...string) *StringBinder

func (*StringBinder) BindWithNewLine added in v0.2.18

func (binder *StringBinder) BindWithNewLine(str ...string) *StringBinder

func (*StringBinder) BindWithSpace added in v0.2.16

func (binder *StringBinder) BindWithSpace(str ...string) *StringBinder

func (*StringBinder) Value added in v0.1.18

func (binder *StringBinder) Value() string

Jump to

Keyboard shortcuts

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