field

package
v0.0.0-...-6f83ac3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeTypes = []TimeTypePattern{
	{Pattern: "time.Time", IsNumeric: true},
	{Pattern: "datatypes.Date", IsNumeric: true},
	{Pattern: "datatypes.Time", IsNumeric: true},
	{Pattern: "datatypes.DateTime", IsNumeric: true},
	{Pattern: "sql.NullTime", IsNumeric: true},
	{Pattern: "pq.NullTime", IsNumeric: true},
}

DefaultTimeTypes contains the built-in time type patterns.

Functions

This section is empty.

Types

type BaseInfo

type BaseInfo struct {
	Name     string // Go field name
	DBName   string // Database column name
	TypeName string // Go type name

	// Type classification flags
	IsStruct  bool // Is a struct type
	IsNumeric bool // Is a numeric type (int, float, etc.)
	IsTime    bool // Is a time-related type
	IsString  bool // Is a string type
	IsSlice   bool // Is a slice type
	IsMap     bool // Is a map type
}

BaseInfo contains basic information about a struct field.

type Field

type Field interface {
	Name() string           // Go field name
	Type() types.Type       // Go type information
	Tag() reflect.StructTag // Struct tags (db:"", json:"", etc.)
}

Field interface defines the contract for struct field information. Provides access to field metadata needed for code generation.

type Info

type Info struct {
	BaseInfo // Embedded base information

	// Enhanced type flags
	IsPointer bool // Is a pointer type
	IsGeneric bool // Has generic type parameters
	// contains filtered or unexported fields
}

Info contains comprehensive field information including type metadata.

func (Info) GetPointed

func (fi Info) GetPointed() Info

GetPointed returns the pointed-to type for pointer fields. Returns zero value if field is not a pointer.

func (Info) GetTypeName

func (fi Info) GetTypeName() string

GetTypeName returns the full type name including generics and pointer information.

func (Info) TypeArgs

func (fi Info) TypeArgs() []*Info

type InfoGenerator

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

InfoGenerator generates field information from Go types. Contains package context for proper type name resolution and configurable time type detection.

func NewInfoGenerator

func NewInfoGenerator(pkg *types.Package) *InfoGenerator

NewInfoGenerator creates a new InfoGenerator with default time type patterns.

func NewInfoGeneratorWithTimeTypes

func NewInfoGeneratorWithTimeTypes(pkg *types.Package, timeTypes []TimeTypePattern) *InfoGenerator

NewInfoGeneratorWithTimeTypes creates a new InfoGenerator with custom time type patterns.

func (*InfoGenerator) AddTimeType

func (g *InfoGenerator) AddTimeType(pattern string, isNumeric bool)

AddTimeType adds a custom time type pattern to the generator.

func (InfoGenerator) GenFieldInfo

func (g InfoGenerator) GenFieldInfo(f Field) *Info

GenFieldInfo generates field information for code generation. Returns nil if the field should be skipped (e.g., tagged with "-").

type TimeTypePattern

type TimeTypePattern struct {
	Pattern   string // Type name pattern (exact match)
	IsNumeric bool   // Whether this time type behaves like numeric for filtering
}

TimeTypePattern represents a pattern for detecting time-related types.

Jump to

Keyboard shortcuts

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