glib

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RandStrModNumber    = 0x01
	RandStrModUpperCase = 0x02
	RandStrModLowerCase = 0x04
)
View Source
const (
	TimeFormatYear2Second = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(ciphertext []byte, key []byte, iv []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(plaintext []byte, key []byte, iv []byte) ([]byte, error)

func BitCount

func BitCount[V constraints.Unsigned](v V) int

func CliNotSetFilled added in v0.0.7

func CliNotSetFilled[T constraints.Ordered](ctx *cli.Context, name string, v T, addr *T) bool

func Copy

func Copy(dst, src interface{}) error

func FileExist

func FileExist(path string) error

func FilesExist

func FilesExist(path ...string) error

func FloatToString

func FloatToString[R constraints.Float](v R, prec int) string

func GetClientIp

func GetClientIp(r *http.Request) string

GetClientIp 获取客户端 ip 地址

func IntegerToString

func IntegerToString[R constraints.Integer](v R) string

func Ip2Long

func Ip2Long(ipStr string) uint32

func IsPublicIP

func IsPublicIP(IP net.IP) bool

IsPublicIP 是否是外网 ip

func JoinFloat

func JoinFloat[T constraints.Float](s []T, sep string, prec int) string

JoinFloat join 浮点型

func JoinInt

func JoinInt[T constraints.Signed](s []T, sep string) string

JoinInt join 有符号整形

func JoinUint

func JoinUint[T constraints.Unsigned](s []T, sep string) string

JoinUint join 无符号整形

func Map2Slice

func Map2Slice[T, R any, K constraints.Ordered](s map[K]T, fn func(k K, v T) R) []R

Map2Slice map 转 切片

func Map2SliceFilter

func Map2SliceFilter[T, R any, K constraints.Ordered](val map[K]T, get func(T) (R, bool)) []R

Map2SliceFilter map 转 切片, 并过滤对应数据

func MapForEach

func MapForEach[K constraints.Ordered, T any](val map[K]T, handle func(K) error) error

func MapKeys

func MapKeys[K constraints.Ordered, V any](m map[K]V) []K

MapKeys 获取 keys

func MapValues

func MapValues[K constraints.Ordered, V any](m map[K]V) []V

MapValues 获取 values

func Md5

func Md5(str string) string

Md5 生成32位MD5摘要

func NetLong2ip

func NetLong2ip(ip uint32) string

NetLong2ip 获得 ip 地址

func ParseGzip

func ParseGzip(data []byte) ([]byte, error)

func RandInt

func RandInt(min, max int) int

RandInt 生成范围内的 int

func RandString

func RandString(length int, chars string, mod uint8) string

RandString 生成随机字符串

func RandStringEx

func RandStringEx(length int) string

func Slice2Map

func Slice2Map[E any, K constraints.Ordered](s []E, fn func(v *E) K) map[K]*E

Slice2Map 切片 转 map

func Slice2MapEx

func Slice2MapEx[T, V any, K constraints.Ordered](arr []T, get func(*T) (K, V)) map[K]V

Slice2MapEx 切片 转 map

func Slice2MapExFilter

func Slice2MapExFilter[T, V any, K constraints.Ordered](arr []T, get func(*T) (K, V, bool)) map[K]V

Slice2MapExFilter 切片 转 map, 并过滤对应数据

func Slice2MapFilter

func Slice2MapFilter[E any, K constraints.Ordered](s []E, fn func(v *E) (K, bool)) map[K]*E

Slice2MapFilter 切片 转 map, 并过滤对应数据

func Slice2Slice

func Slice2Slice[T, R any](arr []T, get func(*T) R) []R

Slice2Slice 切片 转 切片

func Slice2SliceFilter

func Slice2SliceFilter[T, R any](arr []T, get func(*T) (R, bool)) []R

Slice2SliceFilter 切片 转 切片, 并过滤对应数据

func SliceDifference

func SliceDifference[E constraints.Ordered](sliceList ...[]E) []E

SliceDifference 切片差集

func SliceForEach

func SliceForEach[T any](arr []T, handle func(T) bool) bool

SliceForEach 切片遍历

func SliceForEachIdx

func SliceForEachIdx(l int, handle func(i int) bool) bool

SliceForEachIdx 切片遍历

func SliceIntersect

func SliceIntersect[E constraints.Ordered](sliceList ...[]E) []E

SliceIntersect 切片交集

func SliceSortAsc

func SliceSortAsc[T constraints.Ordered](v []T) []T

SliceSortAsc 切片排序(正序)

func SliceSortDesc

func SliceSortDesc[T constraints.Ordered](v []T) []T

SliceSortDesc 切片排序(倒序)

func SliceUnion

func SliceUnion[E constraints.Ordered](sliceList ...[]E) []E

SliceUnion 切片并集

func SliceUnique

func SliceUnique[E constraints.Ordered](v []E) []E

SliceUnique 切片去重

func SplitFloat

func SplitFloat[T constraints.Float](s, sep string) ([]T, error)

SplitFloat split 切割 float

func SplitInt

func SplitInt[T constraints.Signed](s, sep string) ([]T, error)

SplitInt split 切割 int

func SplitSlice

func SplitSlice(v SplitSliceData, sHandle func(b, e int) error) error

SplitSlice split 切割 split

func SplitSliceEx

func SplitSliceEx(v SplitSliceData, sHandle func(b, e int) error, eHandle func(i int) error) error

SplitSliceEx split 切割 split

func SplitUint added in v0.1.1

func SplitUint[T constraints.Unsigned](s, sep string) ([]T, error)

SplitUint split 切割 uint

func StringMerge

func StringMerge(str ...string) string

func StringToFloat

func StringToFloat(v string) float64

func StringToInteger

func StringToInteger(v string) int

func SubStr

func SubStr(str string, start int, end int) string

SubStr 获取子字符串

func TimeFormatInLocation

func TimeFormatInLocation(tm time.Time, layout string) string

func TimeParseInLocation

func TimeParseInLocation(layout, value string) (time.Time, error)

func ToFloat added in v0.1.1

func ToFloat(key interface{}) float64

func ToInt added in v0.1.1

func ToInt(key interface{}) int

func ToString added in v0.1.1

func ToString(key interface{}, limit ...int) string

func VersionCompare

func VersionCompare(version1, version2, operator string) bool

版本对比

Types

type EmptyStruct

type EmptyStruct struct{}

type JsonRawUnmarshalString

type JsonRawUnmarshalString string

func (*JsonRawUnmarshalString) UnmarshalJSON

func (s *JsonRawUnmarshalString) UnmarshalJSON(bytes []byte) error

type JsonStringMarshalStruct

type JsonStringMarshalStruct string

func (JsonStringMarshalStruct) MarshalJSON

func (v JsonStringMarshalStruct) MarshalJSON() ([]byte, error)

type Map4Any

type Map4Any map[string]interface{}

type Set

type Set[T constraints.Ordered] map[T]EmptyStruct

func Slice2Set

func Slice2Set[E any, K constraints.Ordered](s []E, fn func(v *E) K) Set[K]

Slice2Set 切片结构体转换为 map[结构体Field]struct{}

func Slice2SetFilter

func Slice2SetFilter[E any, K constraints.Ordered](s []E, fn func(v *E) (K, bool)) Set[K]

Slice2SetFilter 切片结构体转换为 map[结构体Field]struct{}

func (Set[T]) Add

func (m Set[T]) Add(v T)

func (Set[T]) Has

func (m Set[T]) Has(v T) bool

func (Set[T]) ToSlice

func (m Set[T]) ToSlice() []T

type SplitSliceData

type SplitSliceData interface {
	Len() int
	Compare(i, j int) bool
}

SplitSliceData split 切割 slice 数据结构

Jump to

Keyboard shortcuts

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