Help us shape the future of Go! Take the 2026 Go Developer Survey

modelmeta

package
v0.5.3 Latest Latest
Warning

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

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

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 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.

Jump to

Keyboard shortcuts

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