gofields

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetType

func GetType(t reflect.Type, path string) (reflect.Type, error)

GetType will extract the type at the given path from the data Go struct E.g data = { Friends: []Friend{ { Name: "John" } }, path = "Friends.0.Name" will return "John"

func GetValue

func GetValue(data interface{}, path string) (interface{}, error)

GetValue will extract the value at the given path from the data Go struct E.g data = { Friends: []Friend{ { Name: "John" } }, path = "Friends.0.Name" will return "John"

func ListFields

func ListFields(t reflect.Type) []string

ListFields will recursively list all fields path that can be used with GetType or GetValue

func ListFieldsWithFilter

func ListFieldsWithFilter(t reflect.Type, filter ListFieldFilter) []string

ListFieldsWithFilter is the same as ListFields but accept a filter method that will be call for each fields

Types

type ListFieldFilter

type ListFieldFilter func(reflect.Type, string) bool

Jump to

Keyboard shortcuts

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