minutils

package module
v0.0.1-beta.5 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 13 Imported by: 0

README

minutils

A simple go utils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to text without a memory allocation.

func CleanString

func CleanString(origStr string, args ...bool) string

CleanString 处理字符串, args[0]为是否转换为小写

func CsvToInt32s

func CsvToInt32s(s string) []int32

CsvToInt32s 将逗号分隔的string尝试转换成[1,2,3...]的int32 slice Csv means Comma Separated Value

func CsvToInt64s

func CsvToInt64s(s string) []int64

CsvToInt64s 将逗号分隔的string尝试转换成[1,2,3...]的int64 slice Csv means Comma Separated Value

func CsvToInts

func CsvToInts(s string) []int

CsvToInts 将逗号分隔的string尝试转换成[1,2,3...]的int slice Csv means Comma Separated Value

func FuncEqual

func FuncEqual(fn1, fn2 any) bool

func GetFuncName

func GetFuncName(fn any) string

GetFuncName 从函数实例获取函数名

func GetFuncSignature

func GetFuncSignature(fn any) string

GetFuncSignature 获取函数签名信息

func GetStructName

func GetStructName(obj any) string

GetStructName 获取结构名

func GetVarName

func GetVarName(v any) string

GetVarName 获取变量名

func Int32sToCsv

func Int32sToCsv(int32s []int32) string

Int32sToCsv 将int32 slice转换成用逗号分隔的字符串: 1,2,3

func Int64sToCsv

func Int64sToCsv(int64s []int64) string

Int64sToCsv 将int64 slice转换成用逗号分隔的字符串: 1,2,3

func IsAlphanumeric

func IsAlphanumeric(s string) bool

IsAlphanumeric check if the text contains only letters and numbers. Empty text is valid.

func IsImageData

func IsImageData(data []byte) bool

IsImageData 是否是图像数据

func IsNumeric

func IsNumeric(s string) bool

IsNumeric check if the text contains only numbers. Empty text is valid.

func IsValidMobile

func IsValidMobile(mobile string) bool

IsValidMobile check if the text is valid chinese mobile number

func MatchReceiverMethods

func MatchReceiverMethods(receiver any, matchFn any) map[string]any

MatchReceiverMethods 匹配receiver的所有methods中与matchFn签名参数类似的方法

func OnlyAlphaNumeric

func OnlyAlphaNumeric(s string) string

OnlyAlphaNumeric 去除字符数字以外的所有字符

func OnlyChinese

func OnlyChinese(s string) string

OnlyChinese 去除中文以外的所有字符

func OnlyNumeric

func OnlyNumeric(s string) string

OnlyNumeric 去除数字以外的所有字符

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts text to byte slice without a memory allocation.

func StructSet

func StructSet(obj any, nilField any, val any) error

StructSet 通过反射给结构体obj的nilField类型匹配的field赋值val

func ToBytes

func ToBytes(value any) ([]byte, error)

func ToCamelCase

func ToCamelCase(s string) string

ToCamelCase converts from underscore separated form to camel case form.

func ToFixed

func ToFixed(num float64, precision int) float64

ToFixed 浮点数到指定小数位

func ToInt32s

func ToInt32s(strSlice []string) []int32

ToInt32s 将string slice转换成[1,2,3...]的int32 slice

func ToInt64s

func ToInt64s(strSlice []string) []int64

ToInt64s 将string slice转换成[1,2,3...]的int64 slice

func ToInts

func ToInts(strSlice []string) []int

ToInts 将string slice转换成[1,2,3...]的int slice

func ToSlice

func ToSlice(data any) []any

ToSlice 将传过来的数据转换成[]any

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase converts from camel case form to underscore separated form.

func ToString

func ToString(value any) (string, error)

ToString 尝试将值转换成字符串

Types

type Value

type Value struct {
	Name      string
	IsPointer bool
	Kind      string
	Items     []ValueItem
}

func InspectValue

func InspectValue(v any) *Value

type ValueItem

type ValueItem struct {
	Name  string
	Kind  string
	Value any
}

func GetSliceItems

func GetSliceItems(sv reflect.Value) []ValueItem

func GetStructFields

func GetStructFields(st reflect.Type, sv reflect.Value) []ValueItem

Jump to

Keyboard shortcuts

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