typeutil

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBeanInjectionTarget

func IsBeanInjectionTarget(t reflect.Type) bool

IsBeanInjectionTarget reports whether the provided reflect.Type is a valid target for bean injection.

Valid targets include:

  • a bean type itself
  • collections (map, slice, array) whose element type is a bean

func IsBeanType

func IsBeanType(t reflect.Type) bool

IsBeanType reports whether the provided reflect.Type is considered a "bean" type.

A "bean" type is defined as:

  • a channel type
  • a function type
  • an interface type
  • a pointer to a struct type

func IsConstructor

func IsConstructor(t reflect.Type) bool

IsConstructor reports whether the provided function type is considered a constructor by convention.

A constructor is defined as a function that returns:

  • one non-error value, or
  • two values where the second value is an error.

Examples of valid constructor signatures:

func() *MyStruct
func(cfg Config) (*MyStruct, error)

Examples of invalid constructor signatures:

func()                     // returns nothing
func() error               // returns only an error
func() (*A, *B, error)     // returns more than two values

func IsErrorType

func IsErrorType(t reflect.Type) bool

IsErrorType reports whether the provided reflect.Type represents the built-in error type or a type that implements the error interface.

func IsFuncType

func IsFuncType(t reflect.Type) bool

IsFuncType reports whether the provided reflect.Type represents a function.

func IsPrimitiveValueType

func IsPrimitiveValueType(t reflect.Type) bool

IsPrimitiveValueType reports whether the provided reflect.Type represents a primitive value type such as an integer, unsigned integer, float, string, or boolean.

func IsPropBindingTarget

func IsPropBindingTarget(t reflect.Type) bool

IsPropBindingTarget reports whether the provided reflect.Type is a valid target for property binding.

Valid types include:

  • primitive value types
  • struct types
  • collections (map, slice, array) whose element type is a primitive value or a struct

func ReturnNothing

func ReturnNothing(t reflect.Type) bool

ReturnNothing reports whether the provided function type returns no values. It is useful when analyzing function signatures using reflection.

func ReturnOnlyError

func ReturnOnlyError(t reflect.Type) bool

ReturnOnlyError reports whether the provided function type returns exactly one value and that value is an error.

Types

type FloatType

type FloatType interface {
	~float32 | ~float64
}

FloatType is a generic constraint that represents floating-point types: float32 and float64.

type IntType

type IntType interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

IntType is a generic constraint that represents all signed integer types: int, int8, int16, int32, and int64.

type UintType

type UintType interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

UintType is a generic constraint that represents all unsigned integer types: uint, uint8, uint16, uint32, and uint64.

Jump to

Keyboard shortcuts

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