util

package
v0.0.0-...-5eb3688 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateJwtToken

func CreateJwtToken(data string) (signedToken string, err error)

CreateJwtToken 生成一个jwttoken

func CreateMutiDir

func CreateMutiDir(filePath string) error

调用os.MkdirAll递归创建文件夹

func DateTime

func DateTime(unix int64) (ret string)

DateTime DateTime

func DateTimeFormat

func DateTimeFormat(unix int64, format string) (ret string)

DateTimeFormat DateTimeFormat

func FileExist

func FileExist(path string) bool

判断文件是否存在

func FormatTime

func FormatTime(t time.Time, format string) string

FormatTime 格式化时间显示

func Int64ID

func Int64ID() (int64, error)

func Md5Crypt

func Md5Crypt(str string, salt ...interface{}) (CryptStr string)

func Md5SaltCrypt

func Md5SaltCrypt(str string) (CryptStr string)

func ShowSubstr

func ShowSubstr(s string, l int) string

分割字符串,按指定长度

func VerifyJwtToken

func VerifyJwtToken(jwtToken string) bool

VerifyToken 得到一个JwtToken,然后验证是否合法,防止伪造

Types

type IdWorker

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

func (*IdWorker) InitIdWorker

func (this *IdWorker) InitIdWorker(workerId, datacenterId int64) error

func (*IdWorker) NextId

func (this *IdWorker) NextId() (int64, error)

返回一个唯一的 INT64 ID

type JwtClaims

type JwtClaims struct {
	*jwt.StandardClaims
	//jwt的数据
	Data string
}

创建自己的Claims

func ParseJwtToken

func ParseJwtToken(jwtToken string) (*JwtClaims, error)

ParseJwtToken 解析token得到是自己创建的Claims

type Str

type Str struct{}

func (*Str) DELNbsp

func (this *Str) DELNbsp(txt string) string

删除字符串两端的空格

func (*Str) Escape

func (this *Str) Escape(txt string) string

将特殊字符转义

func (this *Str) GetMDImgLink(txt string) string

匹配到MD文档里的第一个图片的链接,匹配第一个图片链接 返回最后匹配到的(.*)或(.*?)

func (*Str) IsItemStr

func (this *Str) IsItemStr(array []string, val string) bool

数组是否存在某元素 字符串

func (*Str) NumberToInt

func (this *Str) NumberToInt(number string) (int, error)

数字字符串转int

func (*Str) RepMDDesc

func (this *Str) RepMDDesc(txt string, strlen int) string

返回笔记信息列表描述的内容,替换MD的特殊字符

func (*Str) Strip

func (this *Str) Strip(s_ string, chars_ string) string

func (*Str) ToNbsp

func (this *Str) ToNbsp(txt string) string

字符串空格转换html空格

type WebInfo

type WebInfo struct{}
func (this *WebInfo) GetIcoLink(url string) string

获取链接的ico 链接

func (*WebInfo) GetWebTitle

func (this *WebInfo) GetWebTitle(url string) (string, error)

获取链接的 Title

Jump to

Keyboard shortcuts

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