reflectricity

package module
v0.0.0-...-44254a7 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 8 Imported by: 0

README

reflectricity

Reflection tools & helpers

Documentation

Index

Constants

View Source
const (
	CONCAT arrayMergeStrategy = iota
	REPLACE
)

Variables

This section is empty.

Functions

func DeepCopy

func DeepCopy[T any](value T, private bool) T

func RegisterGob

func RegisterGob(value any)

RegisterGob recursively registers a value. Useful when dealing with polymorphic values that need to be written across the wire.

May need Jesus for this one

func ToPtr

func ToPtr[T any](t T) *T

Nests a type into a pointer. Useful for nested pointer definitions when printing a value or a generic way to nest something as a pointer

Types

type Reflector

type Reflector struct {
	// contains filtered or unexported fields
}

func NewReflector

func NewReflector(private bool) *Reflector

func (*Reflector) AddAlias

func (r *Reflector) AddAlias(pkg, alias string)

func (*Reflector) ArrayStrategy

func (r *Reflector) ArrayStrategy(ams arrayMergeStrategy)

func (*Reflector) Merge

func (r *Reflector) Merge(left any, right any) any

Merges 2 structs, field by field replacing all existing field in the right structure into the left. If left is nil returns right. If the types don't match up, returns right

func (*Reflector) PrintValue

func (r *Reflector) PrintValue(i any) string

Print a value as code. Very useful for code generation when a library provides the types being generated

Jump to

Keyboard shortcuts

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