x

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegexpNumeric     = regexp.MustCompile(regexpNumeric)    // 数字格式
	RegexpChinaID     = regexp.MustCompile(regxpChinaID)     // 中国身份证号
	RegexpChinaMobile = regexp.MustCompile(regxpChinaMobile) // 中国11位手机号
	RegexpChinaCarNO  = regexp.MustCompile(regxpChinaCarNO)  // 中国车牌号
)

Functions

func AESDecrypt

func AESDecrypt(key string, iv string, data string) string

AESDecrypt AES 解密内容 AES-128/CBC/PKCS5Padding ,key:32,iv:16

func AESEncrypt

func AESEncrypt(key string, iv string, data string) string

AESEncrypt AES 加密内容 AES-128/CBC/PKCS5Padding ,key:32,iv:16

func ArrayContains

func ArrayContains[T any](array []T, value T) bool

ArrayContains 检查指定元素是否包含在 array 内

func ArrayEmpty

func ArrayEmpty[T any]() []T

ArrayEmpty 返回一个空 array

func FormatChinaMoney

func FormatChinaMoney(value int64) string

FormatChinaMoney 格式化人民币,从分到元

func FormatChinaMoneyWord added in v1.0.5

func FormatChinaMoneyWord(num float64) string

FormatChinaMoneyWord 格式化人民币大写格式

func FormatDate

func FormatDate(dt time.Time) string

FormatDate 格式化时间为 2006-01-02 格式

func FormatDateTime

func FormatDateTime(dt time.Time) string

FormatDateTime 格式化时间为 2006-01-02 15:04:05 格式

func FormatDateTimeLayout added in v1.0.5

func FormatDateTimeLayout(dt time.Time, layout string) string

FormatDateTimeLayout 格式化指定格式的字符串

func FormatKilometer

func FormatKilometer(value int64, scale uint8) string

FormatKilometer 格式化公里,从米到千米

func FormatTime

func FormatTime(dt time.Time) string

FormatTime 格式化时间为 15:04:05 格式

func GeoCheckInAreas added in v1.0.5

func GeoCheckInAreas(point GeoPoint, areas []GeoPoint) bool

GeoCheckInAreas 检查指定点是否在区域内

func GeoHashEncode added in v1.0.3

func GeoHashEncode(longitude float64, latitude float64, precision int) string

GeoHashEncode 输入值:纬度,经度,精度(geohash的长度)

func GeoHashGetNeighbors added in v1.0.3

func GeoHashGetNeighbors(latitude, longitude float64, precision int) []string

GeoHashGetNeighbors 计算该点(latitude, longitude)在精度precision下的邻居 -- 周围8个区域+本身所在区域 返回这些区域的geohash值,总共9个

func GetGoroutineID

func GetGoroutineID() uint64

GetGoroutineID 获取GoroutineID()

func GetLastTime added in v1.0.2

func GetLastTime(t time.Time) time.Time

GetLastTime 获取指定时间最后时刻 23:59:59

func GetMonthFirstDay added in v1.0.9

func GetMonthFirstDay(t time.Time) time.Time

GetMonthFirstDay 获取指定日期的当月首日

func GetMonthLastDay added in v1.0.9

func GetMonthLastDay(t time.Time) time.Time

GetMonthLastDay 获取指定日期的当月最后一日

func GetWeekdayOfDay added in v1.0.8

func GetWeekdayOfDay(t time.Time, weekday time.Weekday) time.Time

GetWeekdayOfDay 获取指定日期本周周几的日期

func GetZeroTime added in v1.0.2

func GetZeroTime(t time.Time) time.Time

GetZeroTime 获取指定时间零点时刻

func HttpGet added in v1.0.1

func HttpGet(requestUrl string) (bool, string, int)

HttpGet 执行Get请求

func HttpPostForm added in v1.0.1

func HttpPostForm(requestUrl string, data url.Values) (bool, string, int)

HttpPostForm 执行Post Form 请求

func HttpPostJson added in v1.0.1

func HttpPostJson(requestUrl string, json string) (bool, string, int)

HttpPostJson 执行Post JSON请求

func HttpPostJsonDownload added in v1.0.9

func HttpPostJsonDownload(requestUrl string, json string) (bool, string, *os.File, int)

HttpPostJsonDownload 执行Post JSON请求并获取响应文件

func HttpPostJsonWithHeader added in v1.0.1

func HttpPostJsonWithHeader(requestUrl string, json string, headers map[string]string) (bool, string, int)

HttpPostJsonWithHeader 执行Post JSON请求

func HttpPostXmlSecure added in v1.0.1

func HttpPostXmlSecure(requestUrl string, xml string, certFile string, keyFile string, rootCaFile string) (bool, string, int)

HttpPostXmlSecure 执行Post XML 证书请求

func JsonToString

func JsonToString(value any) string

JsonToString 转为JSON字符串

func MD5String

func MD5String(plain string) string

MD5String 对字符串MD5处理

func MapContainsKey

func MapContainsKey(key string, m map[string]any) bool

MapContainsKey 是否包含指定键

func MapEmpty

func MapEmpty[T any]() map[string]T

MapEmpty 返回一个空 map

func MapKeys

func MapKeys(m map[string]any) []string

MapKeys 返回键集合

func MaskIDCardNo

func MaskIDCardNo(idno string) string

MaskIDCardNo 身份证脱敏

func MaskMobile

func MaskMobile(mobile string) string

MaskMobile 手机号脱敏

func ParseDate

func ParseDate(value string) time.Time

ParseDate 转换 2006-01-02 格式日期字符串

func ParseDateTime

func ParseDateTime(value string) time.Time

ParseDateTime 转换 2006-01-02 15:04:05 格式时间字符串

func ParseDateTimeLayout

func ParseDateTimeLayout(value string, layout string) time.Time

ParseDateTimeLayout 转换 为指定 格式时间字符串

func ParseLocation

func ParseLocation(value string) (float64, float64)

ParseLocation 转换 lng,lat 格式经纬度字符串,例:113.617525,34.751782

func ParseTime

func ParseTime(value string) time.Time

ParseTime 转换 15:04:05 格式时间字符串

func RandomInt

func RandomInt(minimum int64, maximum int64) int64

RandomInt 随机生成指定区间的数字

func RandomString

func RandomString(count int, letters bool, numbers bool) string

RandomString 生成随机字符

func RatioCalcGrowthRate added in v1.0.4

func RatioCalcGrowthRate(last float64, now float64) float64

RatioCalcGrowthRate 计算环比/同比

func RatioCalcPercent added in v1.0.4

func RatioCalcPercent(total float64, val float64) float64

RatioCalcPercent 计算百分比占比

func SHA1String

func SHA1String(plain string) string

SHA1String 对字符串SHA1处理

func SHA256String

func SHA256String(plain string) string

SHA256String 对字符串SHA256处理

func SHA512String

func SHA512String(plain string) string

SHA512String 对字符串SHA512处理

func SliceContains

func SliceContains[T any](slice []T, value T) bool

SliceContains 检查指定元素是否包含在 slice 内

func SliceEmpty

func SliceEmpty[T any]() []T

SliceEmpty 返回一个空 slice

func SliceIndex added in v1.0.4

func SliceIndex[T any](slice []T, value T) int

SliceIndex 获取指定元素在slice内的索引

func SliceInsert

func SliceInsert[T any](slice []T, index int, value T) []T

SliceInsert 插入元素到指定位置

func SnowfIDWorker

func SnowfIDWorker(workerId, startTime int64) *snowfIDWorker

SnowfIDWorker 创建雪花ID实例

func StringDefaultIfBlank added in v1.0.1

func StringDefaultIfBlank(value, defaultString string) string

StringDefaultIfBlank 返回字符串,若给定的字符串为空,则返回默认字符串

func StringIsAllBlank

func StringIsAllBlank(value ...string) bool

StringIsAllBlank 判断给定的字符串参数中是否全部为空字符串

func StringIsAnyBlank

func StringIsAnyBlank(value ...string) bool

StringIsAnyBlank 判断给定的字符串参数中是否存在空字符串

func StringIsBlank added in v1.0.1

func StringIsBlank(value string) bool

StringIsBlank 判断给定的字符串是否为空字符串

func StringIsNotBlank added in v1.0.1

func StringIsNotBlank(value string) bool

StringIsNotBlank 判断给定的字符串是否为空字符串

func StringLeftPad added in v1.0.1

func StringLeftPad(value string, size int, padString string) string

StringLeftPad 左补齐给定字符串

func StringReverse

func StringReverse(value string) string

StringReverse 反转字符串

func StringRightPad added in v1.0.1

func StringRightPad(value string, size int, padString string) string

StringRightPad 右补齐给定字符串

func Ternary added in v1.0.2

func Ternary[T any](expr bool, first T, second T) T

Ternary 三元表达式

func ToBool

func ToBool(value any) bool

ToBool 转换为 bool 类型

func ToFloat32

func ToFloat32(value any) float32

ToFloat32 转换为 float32 类型

func ToFloat64

func ToFloat64(value any) float64

ToFloat64 转换为 float64 类型

func ToInt

func ToInt(value any) int

ToInt 转换为 int 类型

func ToInt16

func ToInt16(value any) int16

ToInt16 转换为 int16 类型

func ToInt32

func ToInt32(value any) int32

ToInt32 转换为 int32 类型

func ToInt64

func ToInt64(value any) int64

ToInt64 转换为 int64 类型

func ToInt8

func ToInt8(value any) int8

ToInt8 转换为 int8 类型

func ToString

func ToString(value any) string

ToString 转换为 string 类型

func ToUInt

func ToUInt(value any) uint

ToUInt 转换为 uint 类型

func ToUInt16

func ToUInt16(value any) uint16

ToUInt16 转换为 uint16 类型

func ToUInt32

func ToUInt32(value any) uint32

ToUInt32 转换为 uint32 类型

func ToUInt64

func ToUInt64(value any) uint64

ToUInt64 转换为 uint64 类型

func ToUInt8

func ToUInt8(value any) uint8

ToUInt8 转换为 uint8 类型

func XMLFromMap added in v1.0.6

func XMLFromMap(m map[string]string, root string) string

func XMLToMap added in v1.0.6

func XMLToMap(s string) map[string]string

Types

type GeoPoint added in v1.0.5

type GeoPoint struct {
	Lng float64
	Lat float64
}

func NewGeoPoint added in v1.0.5

func NewGeoPoint(latLng string) GeoPoint

NewGeoPoint 生成GeoPoint对象

func NewGeoPoints added in v1.0.5

func NewGeoPoints(latLngs string) []GeoPoint

NewGeoPoints 生成GeoPoint对象数组

type JsonNode

type JsonNode struct {
	// contains filtered or unexported fields
}

JsonNode JSON 结构

func JsonFromString

func JsonFromString(val string, array bool) *JsonNode

JsonFromString 解析JSON字符串,非法字符以{}或[]返回

func JsonFromStringE

func JsonFromStringE(jsonStr string) (*JsonNode, error)

JsonFromStringE 解析JSON字符串数据,并返回解析错误

func (*JsonNode) Boolean

func (n *JsonNode) Boolean() bool

Boolean 获取JSON字段指定的值内容,bool 类型

func (*JsonNode) ContainsKey

func (n *JsonNode) ContainsKey(key string) bool

ContainsKey 是否包含指定Key

func (*JsonNode) Float64

func (n *JsonNode) Float64() float64

Float64 获取JSON字段指定的值内容,float64类型

func (*JsonNode) Index

func (n *JsonNode) Index(index int) *JsonNode

Index 获取JSON数组指定索引的值

func (*JsonNode) Int64

func (n *JsonNode) Int64() int64

Int64 获取JSON字段指定的值内容,int64类型

func (*JsonNode) IsArray

func (n *JsonNode) IsArray() bool

IsArray 是否JSONArray类型

func (*JsonNode) IsEmpty

func (n *JsonNode) IsEmpty() bool

IsEmpty 是否空JSON

func (*JsonNode) IsObject

func (n *JsonNode) IsObject() bool

IsObject 是否JSONObject 类型

func (*JsonNode) Keys

func (n *JsonNode) Keys() []string

Keys 获取JSON对象所有字段名称

func (*JsonNode) Name

func (n *JsonNode) Name(key string) *JsonNode

Name 获取JSON对象指定字段的值

func (*JsonNode) Size

func (n *JsonNode) Size() int

Size 长度,对象类型:字段个数,数组类型:数组长度

func (*JsonNode) String

func (n *JsonNode) String() string

String 获取JSON字段指定的值内容,string 类型

func (*JsonNode) ToArray

func (n *JsonNode) ToArray() []any

ToArray 转换为array []any

func (*JsonNode) ToMap

func (n *JsonNode) ToMap() map[string]any

ToMap 转换为map对象 map[string]any

func (*JsonNode) ToSlice

func (n *JsonNode) ToSlice() []map[string]any

ToSlice 转换为slice []map[string]any

Jump to

Keyboard shortcuts

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