Documentation
¶
Index ¶
- Constants
- Variables
- func As[T Valuer](valuer T, target any) error
- func Equal(a Valuer, b Valuer) bool
- func Merge[T Valuer](base T, patch T, opts ...MergeOption) T
- func Sorted[T Valuer](v T) T
- func ToString(valuer Valuer) string
- type Array
- func (v *Array) Append(item Valuer)
- func (v *Array) Index(i int) (Valuer, bool)
- func (v *Array) IndexedValues() iter.Seq2[int, Valuer]
- func (v *Array) Len() int
- func (v *Array) MarshalJSON() ([]byte, error)
- func (v *Array) String() string
- func (v *Array) UnmarshalJSON(b []byte) error
- func (v *Array) UnmarshalJSONFrom(d *jsontext.Decoder) error
- func (v *Array) Value() any
- func (v *Array) Values() iter.Seq[Valuer]
- type ArrayMergeKeyOption
- type Boolean
- type DiffOption
- type EmptyObjectAsNullOption
- type List
- type MergeOption
- type Null
- type NullOp
- type NullOption
- type Number
- type Obj
- type Object
- func (v *Object) Delete(key string) (didDelete bool)
- func (v *Object) Get(key string) (Valuer, bool)
- func (v *Object) KeyValues() iter.Seq2[string, Valuer]
- func (v *Object) Len() int
- func (v Object) MarshalJSON() ([]byte, error)
- func (v *Object) Set(key string, value Valuer) bool
- func (v *Object) String() string
- func (v *Object) UnmarshalJSON(b []byte) error
- func (v *Object) UnmarshalJSONFrom(d *jsontext.Decoder) error
- func (v *Object) Value() any
- type PatchOp
- type String
- type Valuer
- func Diff[T any](template *T, live *T, opts ...DiffOption) (Valuer, error)
- func FromJSONTextDecoder(decoder *jsontext.Decoder) (Valuer, error)
- func FromValue(value any) (Valuer, error)
- func MustFromValue(value any) Valuer
- func Transform(ctx context.Context, v Valuer, transform func(v Valuer, keyPath ...any) Valuer) Valuer
Constants ¶
View Source
const ( PatchOpReplace = "replace" PatchOpDelete = "delete" )
Variables ¶
View Source
var PatchKey = "$patch"
Functions ¶
func Merge ¶
func Merge[T Valuer](base T, patch T, opts ...MergeOption) T
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
func (*Array) MarshalJSON ¶
func (*Array) UnmarshalJSON ¶
type ArrayMergeKeyOption ¶
type ArrayMergeKeyOption struct {
// contains filtered or unexported fields
}
func WithArrayMergeKey ¶
func WithArrayMergeKey(key string) *ArrayMergeKeyOption
func (*ArrayMergeKeyOption) ApplyToDiff ¶
func (o *ArrayMergeKeyOption) ApplyToDiff(d *differ)
func (*ArrayMergeKeyOption) ApplyToMerge ¶
func (o *ArrayMergeKeyOption) ApplyToMerge(m *merger)
type Boolean ¶
type Boolean struct {
// contains filtered or unexported fields
}
func (*Boolean) MarshalJSON ¶
type DiffOption ¶
type DiffOption interface {
ApplyToDiff(d *differ)
}
type EmptyObjectAsNullOption ¶
type EmptyObjectAsNullOption struct {
// contains filtered or unexported fields
}
func WithEmptyObjectAsNull ¶
func WithEmptyObjectAsNull() *EmptyObjectAsNullOption
func (*EmptyObjectAsNullOption) ApplyToDiff ¶
func (o *EmptyObjectAsNullOption) ApplyToDiff(d *differ)
func (*EmptyObjectAsNullOption) ApplyToMerge ¶
func (o *EmptyObjectAsNullOption) ApplyToMerge(m *merger)
type MergeOption ¶
type MergeOption interface {
ApplyToMerge(m *merger)
}
type NullOption ¶
type NullOption struct {
// contains filtered or unexported fields
}
func WithNullOp ¶
func WithNullOp(op NullOp) *NullOption
func (*NullOption) ApplyToMerge ¶
func (n *NullOption) ApplyToMerge(m *merger)
type Number ¶
type Number[T number] struct {
// contains filtered or unexported fields
}
func (*Number[T]) MarshalJSON ¶
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
func (Object) MarshalJSON ¶
func (*Object) UnmarshalJSON ¶
type String ¶
type String struct {
// contains filtered or unexported fields
}
func (*String) MarshalJSON ¶
type Valuer ¶
func MustFromValue ¶
Click to show internal directories.
Click to hide internal directories.