utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package utils provides type-coercion helpers used to convert loosely-typed input values (from tags, env vars, decoded config) into concrete field types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBool

func ParseBool(val string) bool

ParseBool reports whether val is a truthy string ("true", "yes", "1", case-insensitive) everything else, including unrecognized input, is false.

func ToAnySlice

func ToAnySlice(value any) ([]any, error)

ToAnySlice converts a slice value to []any. []any and []string are handled directly a non-empty string becomes a single-element slice any other slice is converted element-wise via reflection. Non-slice types return an error.

func ToFloat

func ToFloat(value any) (float64, error)

ToFloat converts a numeric or numeric-string value to a float64. It returns an error for unsupported types or unparseable strings.

func ToInt

func ToInt(value any) (int, error)

ToInt converts a numeric or numeric-string value to an int. Floats with a fractional part and unparseable strings return an error.

func ToString

func ToString(value any) (string, error)

ToString converts a string, int, or float value to its string form

Types

This section is empty.

Jump to

Keyboard shortcuts

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