mirror

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: MIT Imports: 6 Imported by: 4

README

mirror

Reflect utilities for Go data types.

API

GetProperty
field, dataType, value, err := mirror.GetProperty(movie, "Title")
field, dataType, value, err := mirror.GetProperty(movie, "Director.Name")
field, dataType, value, err := mirror.GetProperty(movie, "Actors[0].Name")

Using simple queries:

field, dataType, value, err := mirror.GetProperty(movie, `Actors[Name="Tom Cruise"].Name`)

You can not use the . character in query strings yet. This is a bug that needs to be fixed sometime.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetField

func GetField(root interface{}, path string) (*reflect.StructField, reflect.Type, reflect.Value, error)

GetField returns the field referenced by the given path string.

func GetSliceElement

func GetSliceElement(arrayObj interface{}, arrayIndexString string) (value reflect.Value, index int, err error)

GetSliceElement returns the element with the given index or query.

Types

This section is empty.

Jump to

Keyboard shortcuts

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