utils

package
v0.0.0-...-7b661e0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const FormatDate = "2006-01-02"
View Source
const FormatDateTime = "2006-01-02 03:04:05"

Variables

View Source
var ColorSlice = []string{"#CC0033", "#99FF33", "#6600FF", "#999933", "#996699", "#990033", "#66FF33", "#000033", "#0033CC", "#CC3333", "#CCFF99", "#CCFFCC", "#FFCCCC", "#FFFF33", "#990000", "#66CCFF", "#660000", "#333333", "#330000", "#000000"}
View Source
var RedisClient *redis.Client

Functions

func Decode

func Decode(data []byte, to interface{}) error

Decode 用gob进行数据解码

func DelCache

func DelCache(key string) error

DelCache

func Encode

func Encode(data interface{}) ([]byte, error)

Encode 用gob进行数据编码

func GetCache

func GetCache(key string, to interface{}) error

func GetColor

func GetColor(i int) string

func GetDateByClass

func GetDateByClass(class string) (date string)

func GetFirstDateOfMonth

func GetFirstDateOfMonth(d time.Time) time.Time

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

func GetIp

func GetIp()

func GetLastDateOfMonth

func GetLastDateOfMonth(d time.Time) time.Time

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

func GetLengthNameByClass

func GetLengthNameByClass(class string) string

func GetNextNDate

func GetNextNDate(d time.Time, n int) string

周日开始 计算下周一的时间

func GetPreFirstDateOfMonth

func GetPreFirstDateOfMonth(d time.Time) time.Time

获取上个月第一天

func GetRandomString

func GetRandomString(length int, number bool) string

* 获取随机字符串

func GetRedis

func GetRedis() (cli *redis.Client)

连接redis

func GetTimeRange

func GetTimeRange(class string) (timeRange string)

func GetZeroTime

func GetZeroTime(d time.Time) time.Time

获取某一天的0点时间

func InitCache

func InitCache()

func InitLogs

func InitLogs()

func Intf2Int

func Intf2Int(v interface{}) (n int)

func Intf2String

func Intf2String(v interface{}) (str string)

func JDebug

func JDebug(input interface{})

func LogAlert

func LogAlert(v interface{})

func LogCritical

func LogCritical(v interface{})

func LogDebug

func LogDebug(v interface{})

func LogEmergency

func LogEmergency(v interface{})

func LogError

func LogError(v interface{})

func LogInfo

func LogInfo(v interface{})

func LogNotice

func LogNotice(v interface{})

func LogTrace

func LogTrace(v interface{})

func LogWarning

func LogWarning(v interface{})

func MonthRange

func MonthRange() (firstDay, lastDay string)

func Num2Chinese

func Num2Chinese(num int) string

数字转中文大写

func RandomString

func RandomString(length int) string

RandomString 在数字、大写字母、小写字母范围内生成num位的随机字符串

func SetCache

func SetCache(key string, value interface{}, timeout int) error

SetCache

func String2md5

func String2md5(str string) string

将字符串加密成 md5

func SumSlice

func SumSlice(slice []int) int

func TrimHtml

func TrimHtml(src string) string

func UploadImage

func UploadImage(file *multipart.FileHeader, catePath string) (fileFullName string, err error)

@title单图片上传

func UploadImages

func UploadImages(files []*multipart.FileHeader, catePath string) (fileArr []string, err error)

@title 多图片上传

func WeekRange

func WeekRange() (firstDay, lastDay string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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