parser

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldInfo

type FieldInfo struct {
	Name       string
	Type       reflect.Type
	Tag        *TagSpec
	Index      []int // Field index path for embedded structs
	IsEmbedded bool
	FieldName  string // Original struct field name
}

FieldInfo holds information about a struct field

type StructInfo

type StructInfo struct {
	Fields []FieldInfo
}

StructInfo holds metadata about a struct

func ParseStruct

func ParseStruct(t reflect.Type) (*StructInfo, error)

ParseStruct extracts all fields with conform tags

type TagSpec

type TagSpec struct {
	// Source configuration
	EnvVar   string // Environment variable name
	FileKey  string // Key in config file (for nested configs)
	Default  string // Default value if not found
	Required bool   // Is this field required?
	Prefix   string // Prefix for nested structs (e.g. "DB_")

	// Type conversion
	Separator string // For slices: "1,2,3" with separator ","
	Format    string // For time.Time: "2006-01-02"

	// Validation rules
	Validators []Validator
}

TagSpec represents parsed tag information

func ParseTag

func ParseTag(tag string) (*TagSpec, error)

ParseTag parses the conform struct tag Format: conform:"env=PORT,default=8080,validate=gte:1024"

type Validator

type Validator struct {
	Name   string   // "min", "max", "email", "url"
	Params []string // Parameters for validator
}

Validator represents a validation rule

Jump to

Keyboard shortcuts

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