fieldname

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 6 Imported by: ? 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 fieldname resolves explicitly authored MCP field identities. JSON field selection and ordinary decoding remain owned by their existing callers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomJSON

func CustomJSON(t reflect.Type) bool

func HasNames

func HasNames(t reflect.Type, visibility ...Visibility) (bool, error)

HasNames checks the selected ordinary subtree without interpreting custom decoder behavior. A custom owner must provide separate decoding authority if any descendant would acquire an MCP spelling.

func Normalize

func Normalize(t reflect.Type, value any, visibility ...Visibility) (any, error)

Normalize only translates explicitly authored MCP names/aliases into existing JSON member names in ordinary typed bodies. JSON decoding still validates all values. Unknown keys, absence, null and empty objects/arrays are retained. Supplying more than one spelling is always an error, even for equal values.

func OptionalOwner

func OptionalOwner(field reflect.StructField) bool

OptionalOwner reports whether a legacy inline embedding suppresses the required members it contributes. Legacy behavior intentionally does not let required tags on the owner override pointer, omitempty, or optional markers.

func Required

func Required(field reflect.StructField) bool

Required reports the legacy MCP schema requiredness of one selected JSON field. It is schema metadata only; runtime validation is owned elsewhere.

func Validate

func Validate(entries []Entry) error

Validate detects final public collisions without mutating the caller's object.

Types

type Entry

type Entry struct {
	Field    reflect.StructField
	JSONName string
	Name     Name
}

Entry maps a selected original JSON field to its public MCP identity.

func Fields

func Fields(t reflect.Type, visibility ...Visibility) ([]Entry, error)

Fields uses the same native JSON winner selection as the modern reflector. It supplies exact original names/indices; it never invents a second shape.

type Name

type Name struct {
	Public   string
	Aliases  []string
	Hidden   bool
	Explicit bool
}

func Resolve

func Resolve(field reflect.StructField, fallback string) (Name, error)

type Visibility

type Visibility struct {
	ExcludeInternal bool
	ExcludeField    func(reflect.StructField) bool
}

Visibility carries the existing schema owner's selection policy to discovery and invocation. Its zero value preserves ordinary native JSON visibility.

func (Visibility) Excluded

func (v Visibility) Excluded(owner reflect.Type, index []int) bool

Excluded follows the exact native selected index, including promoted owners. Winner selection happens before this check, so excluded winners never expose shadowed fields. Only internal:"true" is hidden by ExcludeInternal.

Jump to

Keyboard shortcuts

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