reflectpath

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyMatcher

type KeyMatcher func(key, pathname string) bool

KeyMatcher is a function that determines whether a property name matches the current path value.

type Resolver

type Resolver struct {
	// KeyMatcher determines whether a structure key matches the current
	// path value. If not set, regular string comparison is used.
	KeyMatcher KeyMatcher
	// AllowedPatterns is a slice of regexp patterns representing
	// paths that are accessible by the Resolver.
	// If not set, there is no restriction.
	AllowedPatterns []string
}

Resolver exposes methods to resolve a string path representation from a host structure and retrieve the matching value or type.

func (Resolver) ResolveType

func (r Resolver) ResolveType(host interface{}, pathRepr string) reflect.Type

ResolveType resolves pathRepr starting from host and returns the matching type.

func (Resolver) ResolveValue

func (r Resolver) ResolveValue(host interface{}, pathRepr string) reflect.Value

ResolveValue resolves pathRepr starting from host and returns the matching value.

Jump to

Keyboard shortcuts

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