zcutil

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToInt32

func BytesToInt32(buf []byte) int32

BytesToInt32 将byte数组转为int32

func CallAsyncFuncAndWaitByFlag added in v0.0.12

func CallAsyncFuncAndWaitByFlag(flagPath, logPath string, funcAsync func() error, timeoutSeconds int) ([]string, error)

func CallAsyncFuncAndWaitByLog added in v0.0.12

func CallAsyncFuncAndWaitByLog(logPath string, funcAsync func() error, funcHandlerLogLine func(line string) (bool, error), timeoutSeconds int) error

CallAsyncFuncAndWaitByLog 调用异步函数并根据日志处理函数等待结束

  • logPath 用于监听异步函数是否执行结束的日志文件,会在调用异步函数funcAsync之前删除
  • funcAsync 异步函数,注意CallAsyncFuncAndWaitByLog内部会在删除日志文件后直接以同步方式调用该函数.即funcAsync的异步处理是由其内部完成的.
  • funcHandlerLogLine 日志按行处理函数,该函数以一行日志为入参,根据该函数的返回值确定是否结束等待.返回bool为true时则结束等待,返回error非空时结束等待并返回该error.
  • timeoutSeconds 等待的超时秒数,超过该时间则立即结束等待并返回超时错误.

该函数内部会先删除logPath文件,然后执行funcAsync,然后tail监听logPath文件,将获取到的每一行日志作为入参调用funcHandlerLogLine进行判断,根据结果决定是否继续tail.如果超时则直接返回超时错误.

func If added in v0.0.12

func If(condition bool, trueVal, falseVal interface{}) interface{}

If 判断条件是否为真,如果为真则返回第一个参数,否则返回第二个参数

func IfByFunc added in v0.0.12

func IfByFunc(condition IfCondition, trueVal IfTrueVal, falseVal IfFalseVal) (interface{}, error)

func IfByFuncNoErr added in v0.0.12

func IfByFuncNoErr(condition IfCondition, trueVal IfTrueValNoError, falseVal IfFalseValNoError) interface{}

func Int32ToBytes

func Int32ToBytes(i int32) []byte

Int32ToBytes 将int32值转为4个字节的byte数组

func PrintStack

func PrintStack(msg string)

PrintStack 打印调用栈

Types

type IfCondition added in v0.0.12

type IfCondition func() bool

type IfFalseVal added in v0.0.12

type IfFalseVal func() (interface{}, error)

type IfFalseValNoError added in v0.0.12

type IfFalseValNoError func() interface{}

type IfTrueVal added in v0.0.12

type IfTrueVal func() (interface{}, error)

type IfTrueValNoError added in v0.0.12

type IfTrueValNoError func() interface{}

Jump to

Keyboard shortcuts

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