structs

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldsSeqFor

func FieldsSeqFor(t typx.Type) iter.Seq[*Field]

func TableFieldsSeq

func TableFieldsSeq(v any) iter.Seq[*TableField]

Types

type Field

type Field struct {
	ColumnName string
	FieldName  string
	Type       typx.Type
	Field      typx.StructField
	Flag       *reflectx.Flag
	Loc        []int
	ColumnDef  def.ColumnDef
}

func FieldsFor

func FieldsFor(t typx.Type) []*Field
Example
fields := structs.FieldsFor(typx.NewRType(reflect.TypeFor[User]()))

for _, f := range fields {
	fmt.Printf("%-10s %-6s %v\n", f.ColumnName, f.Type.Name(), f.Loc)
}

seq := structs.FieldsSeqFor(typx.NewRType(reflect.TypeFor[User]()))
for f := range seq {
	fmt.Printf("%-10s %-6s %v\n", f.ColumnName, f.Type.Name(), f.Loc)
}
Output:

f_id       uint64 [0 0]
f_user_id  uint64 [1 0]
f_org_id   uint64 [2 0]
f_name     string [3 0]
f_age      int    [3 1]
f_id       uint64 [0 0]
f_user_id  uint64 [1 0]
f_org_id   uint64 [2 0]
f_name     string [3 0]
f_age      int    [3 1]

func (*Field) FieldValue

func (f *Field) FieldValue(v reflect.Value) reflect.Value

func (*Field) ModelValue

func (f *Field) ModelValue() reflect.Value

func (*Field) Value

func (f *Field) Value(v reflect.Value) any

type TableField

type TableField struct {
	Field     Field
	Value     reflect.Value
	TableName string
}

func TableFields

func TableFields(v any) []*TableField

Jump to

Keyboard shortcuts

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