utils

package module
v0.0.0-...-bbfc53a Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: GPL-3.0 Imports: 25 Imported by: 0

README

utils

封装了一些常用的公共函数,public function

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmdRun

func CmdRun(ctx context.Context, strCmd string, strArgs ...string) (error, bool)

指定超时时间,调用外部可执行程序运行

func CopyFile

func CopyFile(destPath, srcPath string) error

文件拷贝

func CreateDateDir

func CreateDateDir(basePath string) string

根据当前日期来创建文件夹

func EasyCmdRun

func EasyCmdRun(ctx context.Context, strCmd string, strArgs string) (error, bool)

指定超时时间,调用外部可执行程序运行

func ExpiredDirClean

func ExpiredDirClean(dir string, expiredTime time.Duration) error

func GetFileMd5

func GetFileMd5(path string) string

获取文件的md5值

func GetFileSize

func GetFileSize(fileName string) (int64, error)

func HttpClientCreate

func HttpClientCreate() *http.Client

创建一个http client

func HttpClientGet

func HttpClientGet(netClient *http.Client, url string) (bodyResp []byte, statusCode int, err error)

实现http client get方法的封装

func HttpClientPost

func HttpClientPost(netClient *http.Client, url string, postBody string) (bodyResp []byte, statusCode int, err error)

实现http client post方法的封装

func IsExistFileInfo

func IsExistFileInfo(name string) error

func LargestCommonDivisor

func LargestCommonDivisor(m, n int) int

辗转相除法求最大公约数

func Load

func Load(name string, value interface{}) (err error)

加载配置文件

func LogExit

func LogExit()

func LogInit

func LogInit(log_scribe interface{})

func LogTrace

func LogTrace(log_level LogLevel, log_scribe interface{}, format string, args ...interface{})

添加一个综合的函数

func LogTraceD

func LogTraceD(format string, args ...interface{})

func LogTraceE

func LogTraceE(format string, args ...interface{})

func LogTraceI

func LogTraceI(format string, args ...interface{})

func PanicDump

func PanicDump(err interface{})

func PanicHandler

func PanicHandler()

func PanicTrace

func PanicTrace() string

PanicTrace trace panic stack info.

func PanicTraceEx

func PanicTraceEx()

func Random

func Random() int64

产生一个不同的随机数

func RedisDestroy

func RedisDestroy()

销毁redis pool相关资源

func RedisDo

func RedisDo(cmd string, args ...interface{}) (err error)

func RedisGet

func RedisGet(key string) (value string, err error)

func RedisHGet

func RedisHGet(key, field string) (value string, err error)

HGET key field 返回 key 指定的哈希集中该字段所关联的值

func RedisInit

func RedisInit(server, password string)

初始化

func RedisLLen

func RedisLLen(key string) (value int, err error)

func RedisLPop

func RedisLPop(key string) (value string, err error)

LPOP key 从队列的左边出队一个元素

func RedisLPush

func RedisLPush(key, value string) (err error)

func RedisPoolInit

func RedisPoolInit(server, password string) *redis.Pool

获取一个redis pool

func RedisRPush

func RedisRPush(key, value string) (err error)

func TestCmdRun

func TestCmdRun()

测试

Types

type LogLevel

type LogLevel int32
const (
	DebugLog LogLevel = iota
	InfoLog
	ErrorLog
)

type WaitGroupWrapper

type WaitGroupWrapper struct {
	sync.WaitGroup
}

func (*WaitGroupWrapper) Wrap

func (w *WaitGroupWrapper) Wrap(cb func())

Jump to

Keyboard shortcuts

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