codegen

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoveryConfig

type DiscoveryConfig struct {
	SkipPackages []string
}

DiscoveryConfig holds configuration for struct discovery

type FieldInfo

type FieldInfo struct {
	Name             string
	Type             string
	EncxTags         []string
	IsValid          bool
	ValidationErrors []string
}

FieldInfo contains information about a field with encx tags

type GenerationConfig

type GenerationConfig struct {
	OutputSuffix string
	PackageName  string
}

GenerationConfig holds general generation settings

type StructInfo

type StructInfo struct {
	PackageName       string
	StructName        string
	SourceFile        string
	Fields            []FieldInfo
	HasEncxTags       bool
	GenerationOptions map[string]string // From //encx:options comments
	RequiredImports   map[string]string // package name -> import path
}

StructInfo contains information about a struct with encx tags

func DiscoverStructs

func DiscoverStructs(packagePath string, config *DiscoveryConfig) ([]StructInfo, error)

DiscoverStructs discovers structs with encx tags in the given package path

type TagValidator

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

TagValidator handles validation of encx tags

func NewTagValidator

func NewTagValidator() *TagValidator

NewTagValidator creates a new tag validator

func (*TagValidator) ValidateFieldTags

func (tv *TagValidator) ValidateFieldTags(fieldName string, tags []string) []string

ValidateFieldTags validates the tags for a single field

type TemplateData

type TemplateData struct {
	PackageName        string
	StructName         string
	SourceFile         string
	GeneratedTime      string
	GeneratorVersion   string
	Imports            []string
	EncryptedFields    []TemplateField
	PlainFields        []TemplateField // Non-encx fields copied as-is
	PlainFieldCopies   []string        // Copy statements for plain fields in Process function
	PlainFieldRestores []string        // Copy statements for plain fields in Decrypt function
	ProcessingSteps    []string
	DecryptionSteps    []string
}

TemplateData contains all data needed for code generation

func BuildTemplateData

func BuildTemplateData(structInfo StructInfo, config GenerationConfig) TemplateData

BuildTemplateData builds template data from struct info

type TemplateEngine

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

TemplateEngine manages code generation templates

func NewTemplateEngine

func NewTemplateEngine() (*TemplateEngine, error)

NewTemplateEngine creates a new template engine

func (*TemplateEngine) GenerateCode

func (te *TemplateEngine) GenerateCode(data TemplateData) ([]byte, error)

GenerateCode generates code for a struct using the template

type TemplateField

type TemplateField struct {
	Name      string
	Type      string
	DBColumn  string
	JSONField string
}

TemplateField represents a field in the generated struct

type ValidationError

type ValidationError struct {
	Field   string
	Tag     string
	Message string
}

ValidationError represents a validation error

func (ValidationError) Error

func (ve ValidationError) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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