reflect

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

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

Namespace defines the methods for reflect to be used as template functions.

func New

func New(d *deps.Deps) *Namespace

Creates a new reflect Namespace

func (*Namespace) KindIs

func (ns *Namespace) KindIs(target string, src interface{}) bool

KindIs

Returns true if the target and source types match.

Returns `true` Example: {{ kindIs "int" 123 }}

func (*Namespace) KindOf

func (ns *Namespace) KindOf(src interface{}) string

KindOf

Returns the type of the given `interface` as a string.

Example: {{ kindOf 123 }} Returns: `int`

func (*Namespace) TypeIs

func (ns *Namespace) TypeIs(target string, src interface{}) bool

TypeIs

Similar to `kindIs` but its used for types, instead of primitives.

Example: {{ typeOf "domain.Post" .post }} Returns: `true`

func (*Namespace) TypeIsLike

func (ns *Namespace) TypeIsLike(target string, src interface{}) bool

TypeIsLike

Similar to `kindIs` but its used for types, instead of primitives.

Example: {{ typeOf "domain.Post" .post }} Returns: true

func (*Namespace) TypeOf

func (ns *Namespace) TypeOf(src interface{}) string

TypeOf

Returns the underlying type of the given value.

Example: {{ typeOf .post }} Returns: `domain.Post`

Jump to

Keyboard shortcuts

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