cHelper

package module
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 21 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignStringMappingArrayFields

func AlignStringMappingArrayFields(data []map[string]string) []map[string]string

func ChannelAsyncPush added in v0.0.52

func ChannelAsyncPush[T any](ch chan T, data T)

func Chunk added in v0.0.52

func Chunk[T any](data []T, size uint) (result [][]T)

Chunk 数组分片

func Cmd added in v0.0.52

func Cmd(c CmdOption) (result []byte, err error)

func CopyStringMapping

func CopyStringMapping(data map[string]string) (result map[string]string)

func CopyStringMappingArray

func CopyStringMappingArray(data []map[string]string) (result []map[string]string)

func EmbeddingCos added in v0.0.52

func EmbeddingCos(vector1, vector2 []float64) float64

EmbeddingCos 使用cosine计算向量相似度

func EnvToBool

func EnvToBool(name string, value bool) bool

func EnvToInt

func EnvToInt(name string, value int) int

func EnvToString

func EnvToString(name string, value string) string

func GetFieldValue added in v0.0.52

func GetFieldValue(field string, data interface{}) interface{}

func GetFieldValues added in v0.0.52

func GetFieldValues(field string, data interface{}) []interface{}

func GroupBy added in v0.0.52

func GroupBy[T any](data []T, key func(item T) (string, bool)) (result map[string][]T)

func InArray added in v0.0.52

func InArray[T comparable](array []T, data T) (result bool)

InArray 数组是否存在该值

func InArrayFloat64

func InArrayFloat64(data float64, array []float64) bool

InArrayFloat64 判断是否在数组中,float64

func InArrayInt

func InArrayInt(data int, array []int) bool

InArrayInt 判断是否在数组中,int

func InArrayString

func InArrayString(data string, array []string) bool

InArrayString 判断是否在数组中,string

func IsBool

func IsBool(value interface{}) bool

IsBool 字符串是否为布尔值

func IsDir added in v0.0.52

func IsDir(f string) bool

IsDir 判断目录

func IsEmpty added in v0.0.7

func IsEmpty(value interface{}) bool

func IsExistsPath

func IsExistsPath(f string) bool

IsExistsPath 判断文件是否存在

func IsFloat added in v0.0.7

func IsFloat(value interface{}) bool

IsFloat checks whether `value` is type of float.

func IsInt

func IsInt(value interface{}) bool

IsInt checks whether `value` is type of int.

func IsMap added in v0.0.7

func IsMap(value interface{}) bool

IsMap checks whether `value` is type of map.

func IsNil added in v0.0.7

func IsNil(value interface{}, traceSource ...bool) bool

func IsNumber

func IsNumber(s string) bool

IsNumber 字符串是否为数字

func IsSlice added in v0.0.7

func IsSlice(value interface{}) bool

IsSlice checks whether `value` is type of slice.

func IsString added in v0.0.52

func IsString(value interface{}) bool

IsString 字符串是否为字符串

func IsStruct added in v0.0.7

func IsStruct(value interface{}) bool

IsStruct checks whether `value` is type of struct.

func IsUint added in v0.0.7

func IsUint(value interface{}) bool

IsUint checks whether `value` is type of uint.

func KeyBy added in v0.0.52

func KeyBy[T any](data []T, key func(item T) (string, bool)) (result map[string]T)

func Md5

func Md5(data []byte) string

func MkDirAll added in v0.0.52

func MkDirAll(f string, perm os.FileMode) (err error)

func OrderBy added in v0.0.52

func OrderBy[T any](data []T, compare func(first, second T) (result int))

func PrintMemory added in v0.0.52

func PrintMemory(ctx context.Context, interval int64, handle func(ctx context.Context, mem *MemoryStatus))

func RandomInt

func RandomInt(min, max int) int

RandomInt 生成随机整数

func RandomStr

func RandomStr(length int, randomType RandomType) string

func ReplaceAll

func ReplaceAll(src string, old []string, new string) string

ReplaceAll 多个字符串同时替换为同一个

func SHA1 added in v0.0.52

func SHA1(data string) string

func ToBool

func ToBool(s string) bool

ToBool 字符串转布尔值

func ToFloat32

func ToFloat32(s string) float32

ToFloat32 字符串转32位浮点数

func ToFloat64

func ToFloat64(s string) float64

ToFloat64 字符串转64位浮点数

func ToInt

func ToInt(s string) int

ToInt 字符串转int

func ToInt32

func ToInt32(s string) int32

ToInt32 字符串转int32

func ToInt64

func ToInt64(s string) int64

ToInt64 字符串转int64

func ToInt8

func ToInt8(s string) int8

ToInt8 字符串转int8

func ToString

func ToString(num interface{}) string

ToString 所有类型转字符串

func ToUint

func ToUint(s string) uint

ToUint 字符串转uint

func ToUint32

func ToUint32(s string) uint32

ToUint32 字符串转uint32

func ToUint64

func ToUint64(s string) uint64

ToUint64 字符串转uint64

func ToUint8

func ToUint8(s string) uint8

ToUint8 字符串转uint8

func Ucfirst

func Ucfirst(s string) string

Ucfirst 首字母大写

func UniqueInt64

func UniqueInt64(array []int64) []int64

func Zip added in v0.0.52

func Zip(src string, dest string, ignores ...string) error

Types

type CmdOption added in v0.0.52

type CmdOption struct {
	Command string
	Dir     string
}

type MemoryStatus added in v0.0.52

type MemoryStatus struct {
	Pid  int
	Used int
	G    string
	M    string
	K    string
	Err  error
}

type NumberType added in v0.0.12

type NumberType uint8
const (
	UInt NumberType = iota
	Int
	UFloat
	Float
	Positive
	Negative
	All
)

type RandomType

type RandomType uint8
const (
	RandomType_All RandomType = iota
	RandomType_Number
	RandomType_Char
	RandomType_LowerChar
	RandomType_UpperChar
	RandomType_Symbol
	RandomType_NumberAndSymbol
	RandomType_CharAndSymbol
)

Jump to

Keyboard shortcuts

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