helpers

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpectedStruct = fmt.Errorf("expected a struct")
)
View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func Create

func Create(t reflect.Type) reflect.Value

func CreateFor

func CreateFor[T any]() reflect.Value

func Each

func Each(v any, cb func(v reflect.Value, pointer bool) error) error

func EachField

func EachField(v reflect.Value, cb func(sf reflect.StructField, fv reflect.Value) error) error

func ExponentialFalloff

func ExponentialFalloff(n int) time.Duration

func FieldName

func FieldName(f reflect.StructField) string

func GetFields

func GetFields(t reflect.Type) []reflect.StructField

func GetValue

func GetValue(v any, key string) (any, bool)

func HasField

func HasField(v any, field string) bool

func Includes

func Includes[T comparable](arr []T, v T) bool

func NewOf

func NewOf[T any]() (T, error)

func PrimaryKey

func PrimaryKey(m any) []string

func PrimaryKeyFields

func PrimaryKeyFields(m any) []reflect.StructField

func PrimaryKeyValue

func PrimaryKeyValue(m any) ([]any, error)

func RGetValue

func RGetValue(v reflect.Value, key string) (reflect.Value, error)

func RNewOf

func RNewOf(t reflect.Type) (reflect.Value, error)

func RPrimaryKeyFields

func RPrimaryKeyFields(t reflect.Type) []reflect.StructField

func Zero

func Zero[T any]() T

Types

type PrimaryKeyer

type PrimaryKeyer interface {
	PrimaryKey() []string
}

type Tag

type Tag struct {
	Name          string
	Primary       bool
	Nullable      bool
	AutoIncrement bool
	Readonly      bool
	Index         bool
	Unique        bool
	Type          string
	Size          int
}

func DBTag

func DBTag(f reflect.StructField) *Tag

Jump to

Keyboard shortcuts

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