binder

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binder

type Binder struct {
	// contains filtered or unexported fields
}

Binder handles mapping and execution of field bindings.

func NewBinder

func NewBinder(dst any) (*Binder, error)

NewBinder creates a new binder for the destination object.

func (*Binder) AddBool

func (b *Binder) AddBool(key string, fn func(bool) error)

AddBool registers a custom handler for a boolean field.

func (*Binder) AddDuration

func (b *Binder) AddDuration(key string, fn func(time.Duration) error)

AddDuration registers a custom handler for a duration field.

func (*Binder) AddEnum

func (b *Binder) AddEnum(key string, choices []string, fn func(string) error)

AddEnum registers a handler that validates against a set of allowed values.

func (*Binder) AddInt

func (b *Binder) AddInt(key string, fn func(int64) error)

AddInt registers a custom handler for an integer field.

func (*Binder) AddStrings

func (b *Binder) AddStrings(key string, fn func([]string) error)

AddStrings registers a custom handler for a string slice field.

func (*Binder) Handlers

func (b *Binder) Handlers() map[string]HandlerFunc

Handlers returns the registered handlers.

func (*Binder) Run

func (b *Binder) Run(key string, args []string) error

Run executes the handler for the given key with the provided arguments.

type HandlerFunc

type HandlerFunc func(args []string) error

HandlerFunc handles binding a set of string arguments to a field.

Jump to

Keyboard shortcuts

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