reflection

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: AGPL-3.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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