extendutil

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: BSD-3-Clause Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChToArNumberMap = map[string]int{
	"零": 0,
	"一": 1,
	"二": 2,
	"三": 3,
	"四": 4,
	"五": 5,
	"六": 6,
	"七": 7,
	"八": 8,
	"九": 9,
}

数值对应表

Functions

func Abs added in v0.2.3

func Abs[T PositiveNegativeNumeral](a T) T

func AppendWithUniqueItem

func AppendWithUniqueItem[T Comparable](srcArray []T, items ...T) (result []T)

func ConvertChNumberToArNumber added in v0.2.6

func ConvertChNumberToArNumber(inputStrNum string) (ansNum int)

ConvertChNumberToArNumber 中文数字转阿拉伯数字

func CopyFields added in v0.3.3

func CopyFields(src any, dst any, consistWithSrc ...bool) (err error)

调用时需要确保src和dst是指针类型

func CopyFieldsWithNameArray added in v0.3.3

func CopyFieldsWithNameArray(src any, dst any, names []string) (err error)

调用时需要确保src和dst是指针类型

func Equal

func Equal[T Comparable](a []T, b []T) bool

func ExtractFirstCaptureData

func ExtractFirstCaptureData(src []byte, toFind string) (ret []byte, ok bool)

func GetCaptureBytes

func GetCaptureBytes(data []byte, submatchIndexs []int, index int) (result []byte)

func GetCharOfStringWithIndex added in v0.2.5

func GetCharOfStringWithIndex(src string, index int) (result string, size int)

func GetExecParentDir added in v0.3.1

func GetExecParentDir() (result string, err error)

func GetFirstCharOfString added in v0.2.4

func GetFirstCharOfString(src string) (result string, size int)

func GetGroupIndexPair

func GetGroupIndexPair(index int) (groupBegin, groupEnd int)

func GetUniqueValueArray

func GetUniqueValueArray[T Comparable](valueArray []T) []T

func GetUniqueValueArrayExcludingACertain

func GetUniqueValueArrayExcludingACertain[T Comparable](valueArray []T, certain T) []T

func InterfaceIsNil

func InterfaceIsNil(i interface{}) bool

func IsDir added in v0.3.6

func IsDir(path string) bool

func IsInSlice

func IsInSlice[T Comparable](srcArray []T, item T) bool

检测给定数据项是否在指定Slice中

func JoinBytes

func JoinBytes(sep []byte, pBytes ...[]byte) []byte

func MapToStruct added in v0.2.9

func MapToStruct(m map[string]interface{}, s interface{}) error

func Max

func Max[T IntegerComparable](a, b T) T

func MergeMap

func MergeMap[T Comparable](src map[T]interface{}, others ...map[T]interface{}) map[T]interface{}

func MergeStringMap

func MergeStringMap(src map[string]interface{}, others ...map[string]interface{}) map[string]interface{}

func Min

func Min[T IntegerComparable](a, b T) T

func Reverse

func Reverse(slice interface{})

func ToInt

func ToInt(value interface{}) (int, bool)

func ToString

func ToString(value interface{}) (string, bool)

Types

type Comparable

type Comparable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
		float32 | ~float64 | ~complex64 | ~complex128 |
		string
}

type IntegerComparable

type IntegerComparable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type PositiveNegativeNumeral added in v0.2.3

type PositiveNegativeNumeral interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | float32 | ~float64
}

Jump to

Keyboard shortcuts

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