utils

package
v0.0.0-...-d402f94 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Empty

func Empty(val interface{}) bool

Empty 类似于 PHP 的 empty() 函数

func GenerateCaptcha

func GenerateCaptcha() (id, bs64 string, err error)

GenerateCaptcha 生成验证码

func GetCpuPercent

func GetCpuPercent() float64

func GetDiskPercent

func GetDiskPercent() float64

func GetMemPercent

func GetMemPercent() float64

func GetTime

func GetTime() (retTime string)

GetTime 当前时间

func IsEnv

func IsEnv(eType string) bool

IsEnv 检测环境

func IsGet

func IsGet(c *gin.Context) bool

IsGet 是否是Gost

func IsProd

func IsProd() bool

IsProd 是否是生产环境

func Md5

func Md5(str string) string

Md5 返回一个32位md5加密后的字符串

func NowTime

func NowTime() interface{}

NowTime 获取当前时间

func OSSUploadFile

func OSSUploadFile(c *gin.Context) (bool, string)

func OssUpload

func OssUpload(key string, file io.Reader) (string, error)

func RandomString

func RandomString(length int) string

RandomString 生成长度为 length 的随机字符串

func ReadImgData

func ReadImgData(url string) []byte

ReadImgData 获取C的图片数据

func RepImages

func RepImages(htmls string) string

RepImages 上传给定内容中非本站的图片,并替换为上传的图片链接 https://zhuanlan.zhihu.com/p/74047342

func Upload

func Upload(url string) string

func Uploads

func Uploads(str []interface{}) []interface{}

func Verify

func Verify(id, value string) bool

Verify 验证

Types

type Captcha

type Captcha struct {
	// contains filtered or unexported fields
}

type Merge

type Merge struct {
	Sum      int
	Strings  string
	SumFloat float64
}

func (*Merge) Interface2Type

func (m *Merge) Interface2Type(inter interface{})

Interface2Type 实现传任意多个任意类型的参数 https://github.com/JLynnLee/learnGrammar/blob/1e0f16e5af8ea2ac44e7b5ca93b6af3f0d41ceb1/main.go

type Pagination

type Pagination struct {
	Request *http.Request
	Total   int
	Pernum  int
}

Pagination 分页器

func NewPagination

func NewPagination(req *http.Request, total int, pernum int) *Pagination

NewPagination 新建分页器

func (*Pagination) Pages

func (p *Pagination) Pages() string

Pages 渲染生成html分页标签

type PongoHTML

type PongoHTML struct {
	Template *pongo2.Template
	Name     string
	Data     pongo2.Context
}

func (*PongoHTML) Render

func (p *PongoHTML) Render(w http.ResponseWriter) error

func (*PongoHTML) WriteContentType

func (p *PongoHTML) WriteContentType(w http.ResponseWriter)

type PongoRender

type PongoRender struct {
	TmplDir string
}

func NewRender

func NewRender(tmplDir string) *PongoRender

func (*PongoRender) Instance

func (p *PongoRender) Instance(name string, data interface{}) render.Render

Jump to

Keyboard shortcuts

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