util

package module
v0.0.0-...-73d540b Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

util

Documentation

Index

Constants

View Source
const (
	DEFAULT_NUM = 1
	DEFAULT_STR = "1"
)
View Source
const (
	TIME_FORMAT = "2006-01-02 15:04:05"
	TIME        = tme(0)
)
View Source
const CH_TYPE = chType(0)
View Source
const (
	New = ud(0)
)

Variables

View Source
var (
	ErrInvalidCopyDestination = errors.New("copy destination is invalid")
	ErrInvalidCopyFrom        = errors.New("copy from is invalid")
	ErrMapKeyNotMatch         = errors.New("map's key type doesn't match")
	ErrNotSupported           = errors.New("not supported")
)

Functions

func ChToJsonByTagDB

func ChToJsonByTagDB(src map[string]string, desStruct interface{}) (map[string]string, error)

dbKey to jsonKey like {"id":"aa"} ==>{"ID":"aa"}

func Copy

func Copy(toValue interface{}, fromValue interface{}) (err error)

Copy copy things

func CopyWithOption

func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err error)

CopyWithOption copy with option

func IsEmptyString

func IsEmptyString(s string) bool

func IsNil

func IsNil(param interface{}) bool

func NewRoutineWorker

func NewRoutineWorker() routineWorker

func NewTimeoutWorker

func NewTimeoutWorker(timeout time.Duration) routineWorker

func Run

func Run(ctx Context, worker Worker) error

func ScanDbDataToStruct

func ScanDbDataToStruct(in string, ptrs interface{}) error

dbString==>Struct or *Struct; eg:

  • args in like {"id":"1","name":"zs","h":"1.12"}; key=db_field_name;
  • args ptrs like &Struct{};

func TransFormByTagToMap

func TransFormByTagToMap(ptrs interface{}, tag string) (map[string]interface{}, error)

*Struct or(Struct) ==>map[tagName]interface{} like map[db_name]interface{} ;tag like db

Types

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

func NewContext

func NewContext(ctx context.Context) *Context

arg can be nil

func (*Context) GetArg

func (c *Context) GetArg() interface{}

func (*Context) SetArg

func (c *Context) SetArg(arg interface{}) *Context

type LogBuilder

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

split = ||

func NewLogBuilder

func NewLogBuilder() LogBuilder

func (*LogBuilder) Close

func (t *LogBuilder) Close()

func (*LogBuilder) SetBool

func (t *LogBuilder) SetBool(key string, val bool) *LogBuilder

func (*LogBuilder) SetBytes

func (t *LogBuilder) SetBytes(key string, b []byte) *LogBuilder

func (*LogBuilder) SetFloat32

func (t *LogBuilder) SetFloat32(key string, val float32) *LogBuilder

func (*LogBuilder) SetFloat64

func (t *LogBuilder) SetFloat64(key string, val float64) *LogBuilder

func (*LogBuilder) SetInt

func (t *LogBuilder) SetInt(key string, val int) *LogBuilder

func (*LogBuilder) SetInt32

func (t *LogBuilder) SetInt32(key string, val int32) *LogBuilder

func (*LogBuilder) SetInt64

func (t *LogBuilder) SetInt64(key string, val int64) *LogBuilder

func (*LogBuilder) SetInt8

func (t *LogBuilder) SetInt8(key string, val int8) *LogBuilder

func (*LogBuilder) SetString

func (t *LogBuilder) SetString(key string, val string) *LogBuilder

func (*LogBuilder) SetUint

func (t *LogBuilder) SetUint(key string, val uint) *LogBuilder

func (*LogBuilder) SetUint32

func (t *LogBuilder) SetUint32(key string, val uint32) *LogBuilder

func (*LogBuilder) SetUint64

func (t *LogBuilder) SetUint64(key string, val uint64) *LogBuilder

func (*LogBuilder) SetUint8

func (t *LogBuilder) SetUint8(key string, val uint8) *LogBuilder

func (*LogBuilder) String

func (t *LogBuilder) String() string

type Option

type Option struct {
	// setting this value to true will ignore copying zero values of all the fields, including bools, as well as a
	// struct having all it's fields set to their zero values respectively (see IsZero() in reflect/value.go)
	IgnoreEmpty bool
	DeepCopy    bool
}

Option sets copy options

type Worker

type Worker interface {
	Before(ctx Context) error
	After(ctx Context) error
	Dao(ctx Context) error
}

Jump to

Keyboard shortcuts

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