deep

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilType   = errors.New("type cannot be nil")
	ErrNilTag    = errors.New("tag cannot be nil")
	ErrNilField  = errors.New("field cannot be nil")
	ErrWrongType = errors.New("value has wrong type")
	ErrInternal  = errors.New("internal error")
	ErrInvalid   = errors.New("invalid value")
)

Functions

func AsSlice

func AsSlice(v reflect.Value) []reflect.Value

func Equal

func Equal[T any](env Env, in1, in2 T) bool

func EqualVals

func EqualVals(env Env, v1, v2 reflect.Value) bool

func Format

func Format[T any](env Env, in T) string

func FormatVal

func FormatVal(env Env, v reflect.Value) string

func Order

func Order[T any](env Env, a, b T) int

func OrderVals

func OrderVals(env Env, a, b reflect.Value) int

func TryEqual

func TryEqual[T any](env Env, in1, in2 T) (bool, error)

func TryEqualVals

func TryEqualVals(env Env, v1, v2 reflect.Value) (bool, error)

func TryFormat

func TryFormat[T any](env Env, in T) (string, error)

func TryFormatVals

func TryFormatVals(env Env, v reflect.Value) (string, error)

func Value

func Value[T any](in T) reflect.Value

Types

type Env

type Env interface {
	Get(reflect.Type, Tag) (Val, bool)
}

func NewEnv

func NewEnv(opts ...Opt) Env

func WrapEnv

func WrapEnv(parent Env, opts ...Opt) Env

type EnvSetter

type EnvSetter interface {
	Set(reflect.Type, Tag, Val)
	SetAll(Tag, Val)
}

type Eq

type Eq interface {
	Eq(Env, reflect.Value, reflect.Value) bool
}

type EqDeep

type EqDeep struct{}

func (EqDeep) Eq

func (EqDeep) Eq(env Env, v1, v2 reflect.Value) bool

type EqDefault

type EqDefault struct{}

func (EqDefault) Eq

func (EqDefault) Eq(env Env, v1, v2 reflect.Value) bool

type EqInterface

type EqInterface struct {
	Elem Eq
}

func (EqInterface) Eq

func (ci EqInterface) Eq(env Env, v1, v2 reflect.Value) bool

type EqMap

type EqMap struct {
	Keys Eq
	Vals Eq
}

func (EqMap) Eq

func (cm EqMap) Eq(env Env, v1, v2 reflect.Value) bool

type EqOptFunc

type EqOptFunc func(Env, reflect.Value, reflect.Value) bool

func (EqOptFunc) Eq

func (f EqOptFunc) Eq(env Env, v1, v2 reflect.Value) bool

type EqPointer

type EqPointer struct {
	Elem   Eq
	ByAddr bool
}

func (EqPointer) Eq

func (cp EqPointer) Eq(env Env, v1, v2 reflect.Value) bool

type EqSlice

type EqSlice struct {
	Elems Eq
}

func (EqSlice) Eq

func (cs EqSlice) Eq(env Env, v1, v2 reflect.Value) bool

type EqStruct

type EqStruct struct {
	Fields map[Field]Eq
}

func (EqStruct) Eq

func (cs EqStruct) Eq(env Env, v1, v2 reflect.Value) bool

type EqTrue

type EqTrue struct{}

func (EqTrue) Eq

func (EqTrue) Eq(_ Env, _, _ reflect.Value) bool

type Field

type Field interface {
	GetField(t reflect.Type) reflect.StructField
	// contains filtered or unexported methods
}

func EmbedField

func EmbedField[T any]() Field

func EmbedTypeField

func EmbedTypeField(typ reflect.Type) Field

func NamedField

func NamedField(name string) Field

type Fmt

type Fmt interface {
	Fmt(Env, reflect.Value) string
}

type FmtDeep

type FmtDeep struct{}

func (FmtDeep) Fmt

func (FmtDeep) Fmt(env Env, v reflect.Value) string

type FmtElide

type FmtElide struct{}

func (FmtElide) Fmt

func (FmtElide) Fmt(_ Env, v reflect.Value) string

type FmtFunc

type FmtFunc func(Env, reflect.Value) string

func (FmtFunc) Fmt

func (ff FmtFunc) Fmt(env Env, v reflect.Value) string

type FmtInterface

type FmtInterface struct {
	Elem Fmt
}

func (FmtInterface) Fmt

func (fmtI FmtInterface) Fmt(env Env, v reflect.Value) string

type FmtMap

type FmtMap struct {
	Keys Fmt
	Vals Fmt
}

func (FmtMap) Fmt

func (mf FmtMap) Fmt(env Env, v reflect.Value) string

type FmtPointer

type FmtPointer struct {
	Elem Fmt
}

func (FmtPointer) Fmt

func (pf FmtPointer) Fmt(env Env, v reflect.Value) string

type FmtSlice

type FmtSlice struct {
	Elems Fmt
}

func (FmtSlice) Fmt

func (sf FmtSlice) Fmt(env Env, v reflect.Value) string

type FmtStringer

type FmtStringer struct{}

func (FmtStringer) Fmt

func (FmtStringer) Fmt(_ Env, v reflect.Value) string

type FmtStruct

type FmtStruct struct {
	Fields map[Field]Fmt
}

func (FmtStruct) Fmt

func (sf FmtStruct) Fmt(env Env, v reflect.Value) string

type FmtWrap

type FmtWrap struct {
	Opt  Opt
	Then Fmt
}

func (FmtWrap) Fmt

func (fw FmtWrap) Fmt(env Env, v reflect.Value) string

type MapEntry

type MapEntry struct {
	Key reflect.Value
	Val reflect.Value
}

func AsMapEntries

func AsMapEntries(v reflect.Value) []*MapEntry

type Opt

type Opt interface {
	Update(EnvSetter)
}

func EqOpt

func EqOpt(t reflect.Type, eq Eq) Opt

func EqOptAll

func EqOptAll(eq Eq) Opt

func EqOptBuiltin

func EqOptBuiltin[T comparable]() Opt

func FmtOpt

func FmtOpt(typ reflect.Type, fmt Fmt) Opt

func FmtOptAll

func FmtOptAll(fmt Fmt) Opt

func FmtOptFor

func FmtOptFor[T any](typed func(Env, T) string) Opt

func FmtOptStringer

func FmtOptStringer[T fmt.Stringer]() Opt

func OrdOpt

func OrdOpt(t reflect.Type, ord Ord) Opt

func OrdOptAll

func OrdOptAll(ord Ord) Opt

type OptFunc

type OptFunc func(EnvSetter)

func (OptFunc) Update

func (f OptFunc) Update(setter EnvSetter)

type Opts

type Opts []Opt

func (Opts) Update

func (opts Opts) Update(setter EnvSetter)

type Ord

type Ord interface {
	Ord(Env, reflect.Value, reflect.Value) int
}

type OrdDeep

type OrdDeep struct{}

func (OrdDeep) Ord

func (o OrdDeep) Ord(env Env, v1, v2 reflect.Value) int

type Tag

type Tag any

type Val

type Val any

Jump to

Keyboard shortcuts

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