Documentation ¶
Overview ¶
Package zutil daily development helper functions
Index ¶
- Variables
- func BackOffDelay(attempt int, maxRetryInterval time.Duration) time.Duration
- func CheckErr(err error, exit ...bool)deprecated
- func DoRetry(sum int, fn func() error, opt ...func(*RetryConf)) (err error)
- func GOROOT() string
- func GetAllMethod(s interface{}, fn func(numMethod int, m reflect.Method) error) error
- func GetBuff(ss ...int) *bytes.Buffer
- func GetGid() uint64
- func GetOs() string
- func GetParentProcessName() (string, error)
- func Getenv(name string, def ...string) string
- func IfVal(condition bool, trueVal, falseVal interface{}) interface{}
- func IsDoubleClickStartUp() bool
- func IsLinux() bool
- func IsMac() bool
- func IsWin() bool
- func MaxRlimit() (int, error)
- func Named(name string, arg interface{}) interface{}
- func Once[T any](fn func() T) func() T
- func Optional[T interface{}](o T, fn ...func(*T)) T
- func PutBuff(buffer *bytes.Buffer)
- func ReflectForNumField(v reflect.Value, ...) error
- func ReflectStructField(v reflect.Type, ...) error
- func RunAllMethod(st interface{}, args ...interface{}) (err error)
- func RunAssignMethod(st interface{}, filter func(methodName string) bool, args ...interface{}) (err error)
- func SetValue(vTypeOf reflect.Kind, vValueOf reflect.Value, value interface{}) (err error)
- func Try(fn func(), catch func(e interface{}), finally ...func())deprecated
- func TryCatch(fn func() error) (err error)
- func UnescapeHTML(s string) string
- func WithCompileHandler(fn ArgsCompileHandler) func(args *Args)
- func WithOnlyNamed() func(args *Args)
- func WithRunContext(handler func()) (time.Duration, uint64)
- type Args
- func (args *Args) Compile(format string, initialValue ...interface{}) (query string, values []interface{})
- func (args *Args) CompileArg(buf *bytes.Buffer, values []interface{}, arg interface{}) []interface{}
- func (args *Args) CompileString(format string, initialValue ...interface{}) string
- func (args *Args) Var(arg interface{}) string
- type ArgsCompileHandler
- type ArgsOpt
- type Bool
- type Chan
- type Int32
- type Int64
- type Nocmp
- type Opt
- type Options
- type RetryConf
- type Stack
- type Uint32
- type Uint64
- type Uintptr
Constants ¶
This section is empty.
Variables ¶
var (
BuffSize = bufTypes[3]
)
Functions ¶
func BackOffDelay ¶ added in v1.6.2
func GetAllMethod ¶ added in v0.1.42
GetAllMethod get all methods of struct
func GetParentProcessName ¶ added in v1.1.15
func IfVal ¶
func IfVal(condition bool, trueVal, falseVal interface{}) interface{}
IfVal Simulate ternary calculations, pay attention to handling no variables or indexing problems
func IsDoubleClickStartUp ¶ added in v1.1.15
func IsDoubleClickStartUp() bool
func MaxRlimit ¶ added in v1.1.21
MaxRlimit tries to set the resource limit RLIMIT_NOFILE to the max (hard limit)
func Named ¶ added in v1.3.4
func Named(name string, arg interface{}) interface{}
Named creates a named argument
func Optional ¶ added in v1.7.5
func Optional[T interface{}](o T, fn ...func(*T)) T
Optional Optional parameter
func ReflectForNumField ¶
func ReflectStructField ¶ added in v0.1.43
func RunAllMethod ¶ added in v0.0.26
func RunAllMethod(st interface{}, args ...interface{}) (err error)
RunAllMethod run all methods of struct
func RunAssignMethod ¶ added in v0.1.48
func RunAssignMethod(st interface{}, filter func(methodName string) bool, args ...interface{}) (err error)
RunAssignMethod run assign methods of struct
func Try
deprecated
func Try(fn func(), catch func(e interface{}), finally ...func())
Deprecated: please use zerror.TryCatch Try exception capture
func UnescapeHTML ¶ added in v1.2.0
func WithCompileHandler ¶ added in v1.3.4
func WithCompileHandler(fn ArgsCompileHandler) func(args *Args)
func WithOnlyNamed ¶ added in v1.3.4
func WithOnlyNamed() func(args *Args)
func WithRunContext ¶ added in v1.1.24
WithRunContext function execution time and memory
Types ¶
type Args ¶ added in v1.3.4
type Args struct {
// contains filtered or unexported fields
}
Args stores arguments associated
func (*Args) Compile ¶ added in v1.3.4
func (args *Args) Compile(format string, initialValue ...interface{}) (query string, values []interface{})
Compile compiles builder's format to standard sql and returns associated args
func (*Args) CompileArg ¶ added in v1.3.4
func (*Args) CompileString ¶ added in v1.3.4
CompileString returns a string representation of Args
type ArgsCompileHandler ¶ added in v1.3.4
type RetryConf ¶ added in v1.6.1
type RetryConf struct { // Interval is the interval between retries Interval time.Duration // MaxRetryInterval is the maximum interval between retries MaxRetryInterval time.Duration // Timeout is the timeout of the entire retry Timeout time.Duration // BackOffDelay is whether to increase the interval between retries BackOffDelay bool // contains filtered or unexported fields }
type Uintptr ¶ added in v1.4.4
type Uintptr struct {
// contains filtered or unexported fields
}