util

package
v0.0.0-...-15558e7 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StdChars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")

Functions

func Bytes2str

func Bytes2str(b []byte) string

字符数组转字符串

func CreateDateDir

func CreateDateDir(Path string) string

根据日期创建目录

func CreateDir

func CreateDir(path string)

创建目录

func DateStringToInt

func DateStringToInt(timeSting string) int64

func EncodeMD5

func EncodeMD5(value string) string

EncodeMD5 md5 encryption

func EnsureDir

func EnsureDir(dir string) (err error)

func Float64

func Float64(f float64, n int) float64

func FloatAdd

func FloatAdd(x float64, y float64, more ...float64) float64

浮点加

func FloatEqual

func FloatEqual(f1, f2 float64) bool

是否相等

func FloatGreaterThan

func FloatGreaterThan(f1, f2 float64) bool

大于 >

func FloatGreaterThanOrEqual

func FloatGreaterThanOrEqual(f1, f2 float64) bool

大于等于 >=

func FloatLessThan

func FloatLessThan(f1, f2 float64) bool

小于 <

func FloatLessThanOrEqual

func FloatLessThanOrEqual(f1, f2 float64) bool

小于等于 <=

func FloatMul

func FloatMul(x float64, y float64, more ...float64) float64

浮点乘

func FloatQuo

func FloatQuo(x float64, y float64, more ...float64) float64

浮点除

func FloatSub

func FloatSub(x float64, y float64, more ...float64) float64

浮点减

func GenerateToken

func GenerateToken(username, password string) (string, error)

GenerateToken generate tokens used for auth

func GetCurrentPath

func GetCurrentPath() string

获取当前文件所在的目录

func GetExecpath

func GetExecpath() string

获取当前程序运行目录

func GetFirstDateOfMonth

func GetFirstDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。

func GetLastDateOfMonth

func GetLastDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。

func GetNum

func GetNum() uint8

根据奇偶数返回数字

func GetPage

func GetPage(c *gin.Context) int

GetPage get page parameters

func GetPath

func GetPath(filePath string) string

获取文件的路径

func GetTemplatesPath

func GetTemplatesPath(name string) string

获取模板路径

func GetTwoTimeDuration

func GetTwoTimeDuration(startTime, endTime string) (dutarion string)

获取两个时间相差时长

func GetZeroTime

func GetZeroTime(d time.Time) time.Time

获取某一天的0点时间

func Hash

func Hash(str string) string

func Md5

func Md5(str string) string

func Md5File

func Md5File(file multipart.File) string

文件MD5

func MergeString

func MergeString(args ...string) string

* * @des 拼接字符串 * @param args ...string 要被拼接的字符串序列 * @return string

func NewLenChars

func NewLenChars(length int) string

func PathExists

func PathExists(path string) (bool, error)

func RangeRand

func RangeRand(min, max int64) int64

func RangeSplit

func RangeSplit(num int64, count int64) (res []int64)

将一个数字分成多个数

func Setup

func Setup()

Setup Initialize the util

func Str2bytes

func Str2bytes(s string) []byte

字符串转字符数组

func StrTime

func StrTime(timeStr string) string

* * @des 时间转换函数 * @param timeStr string * @return string

func StrToTime

func StrToTime(str string) time.Time

字符串转换成时间

func TimeStringToInt

func TimeStringToInt(timeSting string) int64

func VerifyEmailFormat

func VerifyEmailFormat(email string) bool

email verify

func VerifyMobileFormat

func VerifyMobileFormat(mobileNum string) bool

mobile verify

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string) (*Claims, error)

ParseToken parsing token

Jump to

Keyboard shortcuts

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