helper

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(n int64) int64

abs

func Base64Decode

func Base64Decode(content string) string

Base64Decode is base64 decode

func Base64Encode

func Base64Encode(content string) string

Base64Encode is base64 encode

func CleanNewline

func CleanNewline(s string) string

CleanNewline is 清理换行符

func CleanSpecialSymbols

func CleanSpecialSymbols(s string) string

CleanSpecialSymbols is 清理特殊符号

func ClearHTML

func ClearHTML(s string) string

ClearHTML is clear html

func ClearSpace

func ClearSpace(s string) string

ClearSpace is clear space

func ClearTGLink(link string) string

ClearLink 清理URL链接

func CompleteBase64URLSafe

func CompleteBase64URLSafe(s string) string

CompleteBase64URLSafe adjusts a Base64 URL-safe encoded string by replacing '-' with '+', '_' with '/', and adding missing padding '=' characters

func Config

func Config(key string) string

Config is get env var

func DetectGenderFromDict

func DetectGenderFromDict(name string) (string, error)

DetectGenderFromDict

func DetermineGender

func DetermineGender(name string) string

检测一个英文名的性别

func EnsureOwner added in v0.1.1

func EnsureOwner(address, message, signature string) (common.Address, error)

EnsureOwner verifies that the signature corresponds to the given address.

func EscapeHTML

func EscapeHTML(content string) string

EscapeHTML is escape HTML

func FindSubstr

func FindSubstr(content string, params ...any) string

FindSubstr 查找截取

func GetBotID

func GetBotID(token string) int64

GetBotID is get bot id

func GetBotToken

func GetBotToken(content string) (string, bool)

GetBotToken is get bot token for content

func GetLinks(s string) []string

GetLinks is get links

func HMAC

func HMAC(h func() hash.Hash, payload []byte, secret []byte) []byte

HMAC is HMAC

func HiddenBotToken

func HiddenBotToken(s string) string

HiddenBotToken is hidden bot token

func IsBotToken

func IsBotToken(token string) bool

IsBotToken is test is bot token

func IsCommand

func IsCommand(text string) bool

IsCommand is check text is command

func IsEnglish

func IsEnglish(str string) bool

检测是否为英文

func IsObjectID

func IsObjectID(v string) bool

IsObjectID is object id

func IsURL

func IsURL(token string) bool

IsURL is test is url

func MD5

func MD5(text string) string

MD5 is md5

func NiceNumber

func NiceNumber(num any) string

NiceNumber is nice number

func Number2Icon

func Number2Icon(number int) string

Number2Icon is number to icon

func RandDoubleAverage

func RandDoubleAverage(count int64, min float64, max float64) float64

RandDoubleAverage 二倍均值算法生成随机数

func RandFloatRange

func RandFloatRange(min float64, max float64) float64

RandFloatRange

func RandRange

func RandRange(min int, max int) int

RandRange is 随机一个范围

func RandString

func RandString(n int) string

RandString is get rand string

func RunesToHexKey

func RunesToHexKey(runes []rune) string

RunesToHexKey - Convert a slice of runes to hex string representation of their Unicode Code Point value

func SignHash added in v0.1.1

func SignHash(data []byte) []byte

SignHash creates a hash for signing a message.

func Split2Tags

func Split2Tags(text string) []string

Split2Tags is split to tags

func StrLen

func StrLen(text string) int

StrLen is get string length

func StrLimit

func StrLimit(text string, length int) string

StrLimit is string limit

func StringToHexKey

func StringToHexKey(input string) string

StringToHexKey - Convert a string to hex string representation of their Unicode Code Point value

func TimestampToTime added in v0.1.2

func TimestampToTime(msTimestamp int64) time.Time

TimestampToTime 将毫秒级时间戳转换为time.Time类型

func ToFloat64

func ToFloat64[T ConvertibleToFloat64](v T) float64

ToFloat64 泛型函数,尝试将不同的类型转换为float64。

func ToInt64

func ToInt64[T ConvertibleToInt64](v T) int64

ToInt64 泛型函数,尝试将不同的类型转换为int64。

func ToObjectID

func ToObjectID[T ConvertibleToObjectID](v T) primitive.ObjectID

ToObjectID 泛型函数,尝试将不同的类型转换为ObjectID。

func ToString

func ToString[T ConvertibleToString](v T) string

ToString 泛型函数,尝试将不同的类型转换为string。

func TrimLastZero

func TrimLastZero(f float64, p ...string) string

TrimLastZero is trim last zero

func UTF8DecodeRune

func UTF8DecodeRune(text string) []string

UTF8DecodeRune is string to Rune

func ValueInSlice

func ValueInSlice[T comparable](v T, slice []T) bool

ValueInSlice 函数检查值v是否存在于切片slice中。 这里使用了泛型,允许对任意可比较的类型进行操作。

Types

type ConvertibleToFloat64

type ConvertibleToFloat64 interface {
	string | float64
}

ConvertibleToFloat64 是一个约束,它匹配所有可以转换为float64的类型。

type ConvertibleToInt64

type ConvertibleToInt64 interface {
	string | int | int32 | int64
}

ConvertibleToInt64 是一个约束,它匹配所有可以转换为int64的类型。

type ConvertibleToObjectID

type ConvertibleToObjectID interface {
	string | primitive.ObjectID
}

ConvertibleToObjectID 是一个约束,它匹配所有可以转换为ObjectID的类型。

type ConvertibleToString

type ConvertibleToString interface {
	float32 | float64 | int | int64 | string
}

ConvertibleToString 是一个约束,它匹配所有可以转换为string的类型。

type EqualsConstraint

type EqualsConstraint[T comparable] interface {
}

EqualsConstraint 约束指定了类型T必须能够与自己进行等值比较。

type JSONBody

type JSONBody map[string]any

JSONBody is send message

func MergeJSON

func MergeJSON(map1 JSONBody, maps ...JSONBody) JSONBody

MergeJSON merge json body

func (JSONBody) Error

func (body JSONBody) Error() string

Error

Jump to

Keyboard shortcuts

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