utils

package module
v0.0.0-...-6ffc9e3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

README

utils

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProcessContextDone = errors.New("process run but upper exit")
)

Functions

func CopyFile

func CopyFile(destPath, srcPath string) error

文件拷贝

func CreateDateDir

func CreateDateDir(basePath string) string

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

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

产生一个不同的随机数

Types

type SubProcess

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

func NewSubProcess

func NewSubProcess() *SubProcess

func (*SubProcess) Run

func (sub *SubProcess) Run(ctx context.Context, ow io.Writer, ew io.Writer, cmd string, args ...string) error

func (*SubProcess) RunWait

func (sub *SubProcess) RunWait(ctx context.Context, ow io.Writer, ew io.Writer, cmd string, args ...string) error

func (*SubProcess) RunWithDir

func (sub *SubProcess) RunWithDir(ctx context.Context, ow io.Writer, ew io.Writer, dir string, cmd string, args ...string) error

func (*SubProcess) Wait

func (sub *SubProcess) Wait(ctx context.Context) error

type WaitGroupWrapper

type WaitGroupWrapper struct {
	sync.WaitGroup
}

func (*WaitGroupWrapper) Wrap

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

Directories

Path Synopsis
Package uniq is a utility package that provides common random unique identifiers in UUID, Base32, and n*2 random hexadecimal characters.
Package uniq is a utility package that provides common random unique identifiers in UUID, Base32, and n*2 random hexadecimal characters.

Jump to

Keyboard shortcuts

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