modelmeta

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package modelmeta shares field naming and tag parsing between declarations and generation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldAt

func FieldAt(model reflect.Type, template, ptr unsafe.Pointer, typ reflect.Type) (int, error)

FieldAt validates a pointer against one exported, unambiguous top-level field.

func FieldMethodPrefix

func FieldMethodPrefix(name string) string

FieldMethodPrefix identifies the shared model field-method convention. Example: FieldMethodPrefix("MutateEmail").

func Fingerprint added in v0.51.0

func Fingerprint(fields []FieldTag) string

Fingerprint covers ordered field names and the presence and exact value of their foundry tag. Length prefixes make the representation unambiguous.

func IdentityVariable added in v0.51.0

func IdentityVariable(table string) string

IdentityVariable lowercases the first word, treating an initialism as one word.

func ModelIdentifier added in v0.51.0

func ModelIdentifier(name string) bool

ModelIdentifier excludes keywords and the blank identifier from generated names.

func NearFoundry added in v0.51.0

func NearFoundry(key string) bool

NearFoundry reports a likely misspelling of the declaration namespace.

func OffsetMatches

func OffsetMatches(t reflect.Type, offset uintptr, target reflect.Type) int

OffsetMatches includes nested fields and zero-sized neighbors in ambiguity checks.

func ParseTags

func ParseTags(text string) (map[string]string, error)

ParseTags rejects malformed and repeated struct tags. Example: ParseTags(`foundry:"-"`).

func Snake

func Snake(name string) string

Snake preserves the generator's column naming convention. Example: Snake("BuyerID").

func ValidMutatorInput

func ValidMutatorInput(t reflect.Type) bool

ValidMutatorInput rejects interfaces and nullable wrappers at declaration boundaries. Example: ValidMutatorInput(reflect.TypeFor[EmailInput]()).

Types

type FieldMethod

type FieldMethod struct {
	Field  string
	Prefix string
	Bound  any
}

FieldMethod describes a validated, unbound model method without invoking it. Example: methods, err := FieldMethods(reflect.TypeFor[Member](), fields).

func FieldMethods

func FieldMethods(model reflect.Type, fields map[string]reflect.Type) ([]FieldMethod, error)

FieldMethods checks value and pointer method sets, retaining value receivers only. Fields contains persisted fields and their non-null stored types.

type FieldTag added in v0.51.0

type FieldTag struct{ Name, Tag string }

FieldTag describes one model field in declaration order. Tag is its whole Go tag.

type ModelTag added in v0.51.0

type ModelTag struct {
	Column                                      string
	DatabaseDefault                             bool
	Role, Input, Mutate, Codec, Member, KeyRole string
	Slot, Ignore                                bool
}

ModelTag is the shared field declaration parsed before type-specific validation. StorageTag retains only the options that describe a persisted column.

func ParseModelTag added in v0.51.0

func ParseModelTag(raw string) (ModelTag, error)

ParseModelTag validates the complete struct tag, including misspelled namespaces. Field type and table-option compatibility are checked by the declaration owner.

func (ModelTag) StorageTag added in v0.51.0

func (t ModelTag) StorageTag() string

StorageTag returns the existing column/default grammar without generator options.

Jump to

Keyboard shortcuts

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