gadget

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const SpanCtxKey = "span_ctx"

Variables

This section is empty.

Functions

func ExtractTraceSpan

func ExtractTraceSpan(ctx context.Context) (spanCtx context.Context, err error)

func GetTableColumn

func GetTableColumn(obj interface{}) []string

func GetTableColumnByTag

func GetTableColumnByTag(obj interface{}, tag string) []string

func IsNumber

func IsNumber(kind reflect.Kind) bool

func RandString

func RandString(len int) string

RandString 生成随机字符串

func StructToMap

func StructToMap(obj interface{}) map[string]interface{}

func StructToMapByJSONTag

func StructToMapByJSONTag(obj interface{}) map[string]interface{}

func UUID

func UUID() string

Types

type ColumnField

type ColumnField struct {
	Name  string
	Field reflect.StructField
}

func NewColumnField

func NewColumnField(field reflect.StructField, name string) ColumnField

type MyStructFields

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

func FieldsFromModel

func FieldsFromModel(m interface{}, db *gorm.DB, recurse bool) (fields MyStructFields)

func FieldsFromStruct

func FieldsFromStruct(t reflect.Type, db *gorm.DB, recurse bool) (fields MyStructFields)

FieldsFromStruct 拿到结构体中的所有属性的字段名,对于嵌套的Struct只递归一次

func (*MyStructFields) Add

func (sf *MyStructFields) Add(fields ...ColumnField)

func (MyStructFields) GetStringField

func (sf MyStructFields) GetStringField() []string

func (*MyStructFields) Merge

func (sf *MyStructFields) Merge(other MyStructFields)

Jump to

Keyboard shortcuts

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