reflectx

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package reflectx provides small reflection helpers.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotStruct = errors.New("reflectx: input must be a struct or non-nil pointer to struct")

ErrNotStruct is returned when Struct2Map receives a nil or non-struct value.

Functions

func Struct2Map

func Struct2Map(obj any) (map[string]any, error)

Struct2Map converts a struct (or pointer to struct) to a map keyed by the json tag name (the part before the first comma). Unexported fields and fields tagged `json:"-"` are skipped; fields without a name in the tag use the Go field name. Options such as omitempty do not affect the key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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