reflectx

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FunctionName

func FunctionName(fn any) string

func IsFunction

func IsFunction(fn any) bool

func IsRefinedType

func IsRefinedType[R any](value reflect.Type) bool

func IsStructMethod

func IsStructMethod(f any) bool

IsStructMethod checks if the provided value is a method expression (e.g., (*Type).Method or Type.Method). It distinguishes between method expressions and regular functions that take struct parameters.

A method expression is created by qualifying a method with a type name, like (*T).Method or T.Method. This is different from: - Regular functions that take struct parameters - Method values (like t.Method where t is an instance) - Anonymous functions

The function works by: 1. Verifying the input is a function with at least one parameter 2. Checking that the first parameter is a struct type (or pointer to struct) 3. Using regex to identify method expressions and extract the type name 4. Comparing the extracted type name with the actual struct type

func IsZero added in v0.0.10

func IsZero(v any) bool

IsZero checks if a value is the zero value for its type. It handles nil values, pointers, interfaces, and all other types. Returns true if the value is zero or nil, false otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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