reflectutil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(val reflect.Value, value string) error

Bind converts a string to a reflect.Value based on its kind.

It supports basic types (string, int, uint, float, bool, duration) and slices of strings.

Example:

var x int
err := reflectutil.Bind(reflect.ValueOf(&x).Elem(), "42")

func BindStruct

func BindStruct(dst any, src map[string]string) error

BindStruct populates a struct from a map[string]string using `conf` tags or field names.

Example:

type Config struct {
	Name  string `conf:"name"`
	Count int    `conf:"count"`
}
var cfg Config
err := reflectutil.BindStruct(&cfg, map[string]string{"name": "test", "count": "42"})

func ParseBoolExtended

func ParseBoolExtended(str string) (bool, error)

ParseBoolExtended parses a boolean string with support for more formats than strconv.ParseBool.

It accepts 1, t, true, yes, y, on as true. It accepts 0, f, false, no, n, off as false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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