util

package
v0.0.0-...-b111a5f Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TIME_FMT = "2006-01-02 15:04"
)

Variables

This section is empty.

Functions

func AvatarResize

func AvatarResize(srcImg image.Image, w, h int, filePath string) error

func CheckError

func CheckError(err error, info string) (res bool)

CheckError error check, 检查到error, 返回true

func CheckImageType

func CheckImageType(buff []byte) string

func CheckTags

func CheckTags(tags string) string

func FetchAvatar

func FetchAvatar(url, save, ua string) error

func FlarumReadLocale

func FlarumReadLocale(flarumDir string, extDirs []string, localeDir, locale string) map[string]string

FlarumReadLocale 读取Flarum的语言包

func GenerateAvatar

func GenerateAvatar(sex, userName string, w, h int, filePath string) error

func GetImageObj

func GetImageObj(buff *bytes.Buffer) (image.Image, error)

func GetImageObj2

func GetImageObj2(buff *bytes.Buffer) (image.Image, error)

func GetLogger

func GetLogger() *logging.Logger

GetLogger 全局使用的Logger

func GetNewToken

func GetNewToken() string

GetNewToken 获取新的csrf token

func GetUUID

func GetUUID() string

GetUUID 获取一个随机的uuid

func HashFileMD5

func HashFileMD5(filePath string) (string, error)

func ImageResize

func ImageResize(srcImg image.Image, w, h int) *image.NRGBA

func InitLogger

func InitLogger(lvl string)

InitLogger 初始化Logger, 未来可以使用文件进行初始化.

func IsMail

func IsMail(str string) bool

func IsNickname

func IsNickname(str string) bool

func IsUserName

func IsUserName(str string) bool

func RemoveCharacter

func RemoveCharacter(str string) string

func SliceUniqInt

func SliceUniqInt(s []int) []int

func SliceUniqStr

func SliceUniqStr(s []string) []string

func TimeFmt

func TimeFmt(tp interface{}, sample string, tz int) string

TimeFmt 格式化时间戳

func TimeHuman

func TimeHuman(ts interface{}) string

TimeHuman 给人类看的时间

func TimeNow

func TimeNow() uint64

TimeNow 当前时间

func VerifyToken

func VerifyToken(realToken, sentToken string) bool

VerifyToken verifies the sent token equals the real one and returns a bool value indicating if tokens are equal. Supports masked tokens. realToken comes from Token(r) and sentToken is token sent unusual way.

Types

This section is empty.

Jump to

Keyboard shortcuts

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