utils

package
v0.0.0-...-f0dea4b Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

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

Decode 用gob进行数据解码

func Encode

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

Encode 用gob进行数据编码

func GetCache

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

func InitCache

func InitCache()

func InitLogs

func InitLogs()

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 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

Types

type Paginator

type Paginator struct {
	Request     *http.Request
	PerPageNums int
	MaxPages    int
	// contains filtered or unexported fields
}

Paginator 分页类

func NewPaginator

func NewPaginator(r *http.Request, nums int64) *Paginator

NewPaginator 创建分页对象

func (*Paginator) End

func (p *Paginator) End() int

End 最后元素

func (*Paginator) HasNext

func (p *Paginator) HasNext() bool

HasNext 是否存在下一页

func (*Paginator) HasPages

func (p *Paginator) HasPages() bool

HasPages 存在分页

func (*Paginator) HasPrev

func (p *Paginator) HasPrev() bool

HasPrev 是否存在上一页

func (*Paginator) IsActive

func (p *Paginator) IsActive(page int) bool

IsActive 是否为当前页

func (*Paginator) Nums

func (p *Paginator) Nums() int64

Nums 总个数

func (*Paginator) Offset

func (p *Paginator) Offset() int

Offset 偏移量

func (*Paginator) Page

func (p *Paginator) Page() int

Page 当前页

func (p *Paginator) PageLink(page int) string

PageLink 分页链接

func (*Paginator) PageLinkFirst

func (p *Paginator) PageLinkFirst() (link string)

PageLinkFirst 第一页

func (*Paginator) PageLinkLast

func (p *Paginator) PageLinkLast() (link string)

PageLinkLast 最后一页

func (*Paginator) PageLinkNext

func (p *Paginator) PageLinkNext() (link string)

PageLinkNext 下一页

func (*Paginator) PageLinkPrev

func (p *Paginator) PageLinkPrev() (link string)

PageLinkPrev 上一页

func (*Paginator) PageNums

func (p *Paginator) PageNums() int

PageNums 分页总页数

func (*Paginator) Pages

func (p *Paginator) Pages() []int

Pages 页数

Jump to

Keyboard shortcuts

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