helper

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnImplements

func OnImplements(t reflect.Type, iface reflect.Type, input reflect.Value, op TransformFunc) (reflect.Value, error)

OnImplements automatically negotiates between pointered and concrete types. `t` is the source type. `iface` is the interface type we're checking. `input` is the seed value that will be operated on if t implements iface in one form or another and returned unmodified if it doesn't implement the interface. `op` is the operation that will be run if `t` implements `iface`. It is passed the input, and a new value in the proper form of `t` and should return a modified value and an error. This function returns the proper form of the modified value or the original unmodified input.

Types

type TransformFunc

type TransformFunc func(input reflect.Value, v reflect.Value) (reflect.Value, error)

TransformFunc is a function that runs when a particular reflect.Type implements an interface.

Jump to

Keyboard shortcuts

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