helper

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 18 Imported by: 7

README

Helper

这都是辅助函数,方便开发调用。

go get github.com/EasyMeta-App/helper
package main

import "github.com/EasyMeta-App/helper"

func main() {
  resp := helper.RandString(5)
  fmt.Println(resp)
}
├── LICENSE
├── README.md
├── any2type.go
├── array.go
├── bot.go
├── config.go
├── crypto.go
├── gender.go
├── gender_test.go
├── go.mod
├── go.sum
├── html.go
├── init.go
├── json.go
├── names
│   ├── yob1880.txt
│   ├── yob1881.txt
│   ├── ...
├── numbers.go
├── random.go
├── strings.go
├── strings_test.go
└── validate.go

1 directories, 161 files

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 added in v0.1.2

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 EscapeHTML

func EscapeHTML(content string) string

EscapeHTML is escape HTML

func FindSubstr

func FindSubstr(content string, params ...interface{}) 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 interface{}) 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 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 StringInArray

func StringInArray(value string, lists []string) bool

StringInArray is value in string array

func StringToHexKey

func StringToHexKey(input string) string

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

func ToFloat64

func ToFloat64(v interface{}) float64

ToFloat64 is interface to float64

func ToInt64

func ToInt64(v interface{}) int64

ToInt64 is interface to int64

func ToObjectID

func ToObjectID(v interface{}) primitive.ObjectID

ToObjectID is interface to ObjectID

func ToString

func ToString(v interface{}) string

ToString is interface to 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

Types

type JSONBody

type JSONBody map[string]interface{}

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