meta

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field interface {
	// Return the field name
	Name() string

	// Return the underlying type (dereferencing pointers)
	Type() reflect.Type

	// Return the index of the field
	Index() []int

	// Whether the field has a tag ie, Is("omitempty")
	Is(name string) bool

	// Return the tag value for a field
	Tag(name string) string

	// Return tuple value
	Tuple(name string) string

	// Return omit flag
	Omit() bool

	// Set omit flag
	SetOmit(bool)
}

The field metadata

type Iterator

type Iterator interface {
	// Return the number of elements
	Len() int

	// Return the next struct, or nil
	Next() any

	// Reset the iterator to the beginning
	Reset()
}

Iterator is an interface for iterating over a slice of struct values

func NewIterator

func NewIterator(v any) (Iterator, error)

NewIterator returns a new slice iterator object, from a single struct value or an array of one or more struct values which are of the same type

type Struct

type Struct interface {
	// Return the underlying type
	Type() reflect.Type

	// Return field metadata
	Fields() []Field

	// Return the field values in the correct order
	Values(v any) ([]any, error)
}

The struct metadata

func New

func New(v any, tags ...string) (Struct, error)

Create a new metadata object from a struct value and optional set of tags

func NewType added in v0.0.7

func NewType(rt reflect.Type, tags ...string) (Struct, error)

Create a new metadata object from a reflect.Type and optional set of tags

Jump to

Keyboard shortcuts

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