go_utils

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CWD

func CWD() string

func CreateClient

func CreateClient(accessKeyId *string, accessKeySecret *string) (_result *dysmsapi20170525.Client, _err error)

func CreateDir

func CreateDir(dirs ...string) (err error)

func CurrentDir

func CurrentDir() (string, error)

func FileMove

func FileMove(src string, dst string) (err error)

func FilterGormError

func FilterGormError(err error) error

func GetFileModTime

func GetFileModTime(path string) int64

获取文件修改时间 返回unix时间戳

func GetFuncName

func GetFuncName() string

获取正在运行的函数名

func IsGormNotFound

func IsGormNotFound(err error) bool

func JSONStringify

func JSONStringify(in interface{}) (status bool, retStr string)

数据序列化

func PathExists

func PathExists(path string) (bool, error)

func Printf

func Printf(title string, value interface{})

func Println

func Println(title string)

func QrCodeBase64

func QrCodeBase64(content string) string

func RandFloat64

func RandFloat64() float64

func RandInt

func RandInt(min int, max int) int

func RandString

func RandString(len int) string

func ReadFileString

func ReadFileString(filePath string) string

读取文件

func SMSSendAliyun

func SMSSendAliyun(accessKeyId, accessKeySecret, PhoneNumbers, SignName, TemplateCode, TemplateParam, SmsUpExtendCode, OutId string) (err error)

func ZipFiles

func ZipFiles(filename string, files []string, oldform, newform string) error

Types

type Crontab

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

Crontab crontab manager

func NewCrontab

func NewCrontab() *Crontab

NewCrontab new crontab

func (*Crontab) AddByFunc

func (c *Crontab) AddByFunc(id string, spec string, f func()) error

AddByFunc add function as crontab task

func (*Crontab) AddByID

func (c *Crontab) AddByID(id string, spec string, cmd cron.Job) error

AddByID add one crontab task id is unique spec is the crontab expression

func (*Crontab) DelByID

func (c *Crontab) DelByID(id string)

DelByID remove one crontab task

func (*Crontab) IDs

func (c *Crontab) IDs() []string

IDs ...

func (*Crontab) IsExists

func (c *Crontab) IsExists(jid string) bool

IsExists check the crontab task whether existed with job id

func (*Crontab) Start

func (c *Crontab) Start()

Start start the crontab engine

func (*Crontab) Stop

func (c *Crontab) Stop()

Stop stop the crontab engine

type Paging

type Paging struct {
	Page      uint //当前页
	PageSize  uint //分页每页条数
	TotalItem uint //内容总条数
	TotalPage uint //分页总数
}

func PagingGenerater

func PagingGenerater(page, pageSize, total uint) (paging Paging)

func (*Paging) GetQueryBegin

func (p *Paging) GetQueryBegin() (begin uint)

func (*Paging) GetQueryRangeMySQL

func (p *Paging) GetQueryRangeMySQL() (sql string)

func (*Paging) SetData

func (p *Paging) SetData() (begin uint)

type XLog

type XLog struct{}

XLog 日志类

func (*XLog) Debug

func (self *XLog) Debug(args ...interface{})

一下是各种级别的记录,直接调用 logrus

func (*XLog) Error

func (self *XLog) Error(args ...interface{})

func (*XLog) Fatal

func (self *XLog) Fatal(args ...interface{})

func (*XLog) Info

func (self *XLog) Info(args ...interface{})

func (*XLog) Init

func (self *XLog) Init(logFile string, runEnv string, withFileDetail bool)

初始化 runEnv 为环境: production 为生产环境

func (*XLog) LogMap

func (self *XLog) LogMap(msg string, prefix string, data XLogFields)

LogMap 记录 map 类型

func (*XLog) Logf

func (self *XLog) Logf(msg string, prefix string, data interface{})

Logf 记录复杂数据类型

func (*XLog) Logln

func (self *XLog) Logln(msg string, prefix string)

Logln 记录字符串

func (*XLog) Panic

func (self *XLog) Panic(args ...interface{})

func (*XLog) Warn

func (self *XLog) Warn(args ...interface{})

type XLogFields

type XLogFields = logrus.Fields

type XLogFormatter

type XLogFormatter struct{} //自定义日志格式

func (*XLogFormatter) Format

func (s *XLogFormatter) Format(entry *logrus.Entry) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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