utils

package
v0.0.0-...-91dbda9 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KC_RAND_KIND_NUM   = 0 // 数字
	KC_RAND_KIND_LOWER = 1 // 小写字母
	KC_RAND_KIND_UPPER = 2 // 大写字母
	KC_RAND_KIND_ALL   = 3 // 全部
)
View Source
const (
	Version           = "1.0"
	StoreLocal string = "local"
	StoreOss   string = "oss"
)

更多存储类型有待扩展

Variables

View Source
var (
	BasePath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
	StoreType   = beego.AppConfig.String("store_type") //存储类型
)
View Source
var BooksRelease = BooksLock{Books: make(map[int]bool)}

Functions

func Decode

func Decode(value string, r interface{}) error

解码

func Encode

func Encode(value interface{}) (string, error)

编码

func FormatBytes

func FormatBytes(size int64) string

func HttpPostJson

func HttpPostJson(url, body string) (*simplejson.Json, error)

func HttpPutJson

func HttpPutJson(url, body string) error

func InMap

func InMap(maps map[int]bool, key int) (ret bool)

判断数据是否在map中

func Krand

func Krand(size int, kind int) []byte

func NewPaginations

func NewPaginations(rollPage, totalRows, listRows, currentPage int, urlPrefix string, urlSuffix string, urlParams ...interface{}) html1.HTML

分页函数(这个分页函数不具有通用性) rollPage:展示分页的个数 totalRows:总记录 currentPage:每页显示记录数 urlPrefix:url链接前缀 urlParams:url键值对参数

func ParseTitleFromMdHtml

func ParseTitleFromMdHtml(html string) (title string)

从md的html文件中提取文章标题(从h1-h6)

func PasswordHash

func PasswordHash(pass string) (string, error)

func PasswordVerify

func PasswordVerify(hashing string, pass string) (bool, error)

func ScoreFloat

func ScoreFloat(score int) string

评分处理

func ShowImg

func ShowImg(img string, style ...string) (url string)

操作图片显示 如果用的是oss存储,这style是avatar、cover可选项

func Substr

func Substr(s string, length int) string

Substr returns the substr from start to length.

Types

type BooksLock

type BooksLock struct {
	Books map[int]bool
	Lock  sync.RWMutex
}

书籍发布锁

func (BooksLock) Delete

func (this BooksLock) Delete(bookId int)

删除

func (BooksLock) Exist

func (this BooksLock) Exist(bookId int) (exist bool)

查询发布任务

func (BooksLock) Set

func (this BooksLock) Set(bookId int)

设置

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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