reflection

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package reflection provides utilities for struct field inspection, tag extraction, and dynamic method introspection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFieldTypes

func GetFieldTypes(strukt any) (map[string]any, error)

GetFieldTypes returns a map of field names to their types. For nested structs, the value is a map[string]any containing the nested struct's fields.

func GetMethodName

func GetMethodName(method any) string

GetMethodName is meant to fetch the name of a given method passed in as an argument.

func GetTagNameByValue

func GetTagNameByValue(strukt, fieldValue any, tagKey string) (string, error)

GetTagNameByValue searches struct s (or *s) for a field whose value equals fieldValue and returns the tag for tagKey (e.g. "json") for the first match. It returns an error if s is not a struct or no matching field is found.

Notes & limitations: - It compares field values using reflect.DeepEqual. - Unexported fields are skipped (fv.CanInterface() == false). - If multiple fields have identical values, the first match is returned (search order is struct field order). - This requires passing the originating struct instance; a bare field value alone is insufficient in Go.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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