zutil

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 18 Imported by: 32

Documentation

Overview

Package zutil daily development helper functions

Index

Constants

This section is empty.

Variables

View Source
var (
	BuffSize = bufTypes[3]
)

Functions

func CheckErr deprecated

func CheckErr(err error, exit ...bool)

Deprecated: please use zerror.Panic CheckErr Check Err

func GOROOT added in v1.2.0

func GOROOT() string

func GetAllMethod added in v0.1.42

func GetAllMethod(s interface{}, fn func(numMethod int, m reflect.Method) error) error

GetAllMethod get all methods of struct

func GetBuff

func GetBuff(ss ...int) *bytes.Buffer

func GetGid added in v1.1.17

func GetGid() uint64

GetGid Get coroutine id

func GetOs added in v0.1.59

func GetOs() string

func GetParentProcessName added in v1.1.15

func GetParentProcessName() (string, error)

func Getenv added in v0.1.59

func Getenv(name string, def ...string) string

Getenv get ENV value by key name

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 IsLinux added in v0.1.59

func IsLinux() bool

IsLinux system

func IsMac added in v0.1.59

func IsMac() bool

IsMac system

func IsWin added in v0.1.59

func IsWin() bool

IsWin system. linux windows darwin

func MaxRlimit added in v1.1.21

func MaxRlimit() (int, error)

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 Once added in v1.1.25

func Once(fn func() interface{}) func() interface{}

Once initialize the singleton

func PutBuff

func PutBuff(buffer *bytes.Buffer)

func ReflectForNumField

func ReflectForNumField(v reflect.Value, fn func(fieldName, fieldTag string,
	kind reflect.Kind, field reflect.Value) error, tag ...string) error

func ReflectStructField added in v0.1.43

func ReflectStructField(v reflect.Type, fn func(
	numField int, fieldTag string, field reflect.StructField) error, tag ...string) error

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 SetValue

func SetValue(vTypeOf reflect.Kind, vValueOf reflect.Value, value interface{}) (err error)

func Try deprecated

func Try(fn func(), catch func(e interface{}), finally ...func())

Deprecated: please use zerror.TryCatch Try exception capture

func TryCatch added in v1.1.12

func TryCatch(fn func() error) (err error)

TryCatch exception capture

func UnescapeHTML added in v1.2.0

func UnescapeHTML(s string) string

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

func WithRunContext(handler func()) (time.Duration, uint64)

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 NewArgs added in v1.3.4

func NewArgs(opt ...ArgsOpt) *Args

NewArgs returns a new Args

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 *Args) CompileArg(buf *bytes.Buffer, values []interface{}, arg interface{}) []interface{}

func (*Args) CompileString added in v1.3.4

func (args *Args) CompileString(format string, initialValue ...interface{}) string

CompileString returns a string representation of Args

func (*Args) Map added in v1.3.4

func (args *Args) Map(arg interface{}) string

Map adds an arg to Args and returns a placeholder

type ArgsCompileHandler added in v1.3.4

type ArgsCompileHandler func(buf *bytes.Buffer, values []interface{}, arg interface{}) ([]interface{}, bool)

type ArgsOpt added in v1.3.4

type ArgsOpt func(*Args)

type Bool added in v1.3.0

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

func NewBool added in v1.3.0

func NewBool(b bool) *Bool

func (*Bool) CAS added in v1.3.0

func (b *Bool) CAS(old, new bool) bool

func (*Bool) Load added in v1.3.0

func (b *Bool) Load() bool

func (*Bool) Store added in v1.3.0

func (b *Bool) Store(val bool) bool

func (*Bool) Toggle added in v1.3.0

func (b *Bool) Toggle() (old bool)

type Int32 added in v1.3.0

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

func NewInt32 added in v1.3.0

func NewInt32(i int32) *Int32

func (*Int32) Add added in v1.3.0

func (i32 *Int32) Add(i int32) int32

func (*Int32) CAS added in v1.3.0

func (i32 *Int32) CAS(old, new int32) bool

func (*Int32) Load added in v1.3.0

func (i32 *Int32) Load() int32

func (*Int32) Store added in v1.3.0

func (i32 *Int32) Store(i int32)

func (*Int32) String added in v1.3.0

func (i32 *Int32) String() string

func (*Int32) Sub added in v1.3.0

func (i32 *Int32) Sub(i int32) int32

func (*Int32) Swap added in v1.3.0

func (i32 *Int32) Swap(i int32) int32

type Int64 added in v1.3.2

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

func NewInt64 added in v1.3.2

func NewInt64(i int64) *Int64

func (*Int64) Add added in v1.3.2

func (i64 *Int64) Add(i int64) int64

func (*Int64) CAS added in v1.3.2

func (i64 *Int64) CAS(old, new int64) bool

func (*Int64) Load added in v1.3.2

func (i64 *Int64) Load() int64

func (*Int64) Store added in v1.3.2

func (i64 *Int64) Store(i int64)

func (*Int64) String added in v1.3.2

func (i64 *Int64) String() string

func (*Int64) Sub added in v1.3.2

func (i64 *Int64) Sub(i int64) int64

func (*Int64) Swap added in v1.3.2

func (i64 *Int64) Swap(i int64) int64

type Nocmp added in v1.3.0

type Nocmp [0]func()

Nocmp is an uncomparable struct

type Stack added in v1.2.0

type Stack []uintptr

Stack uintptr array

func Callers added in v1.2.0

func Callers(skip ...int) Stack

func (Stack) Format added in v1.2.0

func (s Stack) Format(f func(fn *runtime.Func, file string, line int) bool)

Directories

Path Synopsis
Package daemon program is installed as a system service to achieve process daemon
Package daemon program is installed as a system service to achieve process daemon

Jump to

Keyboard shortcuts

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