utils

package module
v0.0.0-...-5e38549 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: GPL-3.0 Imports: 22 Imported by: 0

README

utils

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmdRunProcess

func CmdRunProcess(chKill chan string, strCmd string, strArgs ...string) error

运行外部程序,通过给chCmd发送消息来实现结束这个外部进程

func CmdRunWithTimeout

func CmdRunWithTimeout(ctx context.Context, timeout time.Duration, strCmd string, strArgs ...string) (error, bool)

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

func EasyCmdRunWithTimeout

func EasyCmdRunWithTimeout(ctx context.Context, timeout time.Duration, strCmd string, strArgs string) (error, bool)

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

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