types

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteMultiplier added in v1.5.0

func ByteMultiplier(unit string) (int64, bool)

ByteMultiplier exposes the normalized multiplier lookup for other packages.

func Convert

func Convert(value string, target reflect.Value) error

Convert converts a string value to the target reflect.Value's type.

func ParseBytes added in v1.5.0

func ParseBytes(s string) (int64, error)

ParseBytes parses a string representation of bytes into an int64. It supports both pure numbers and size suffixes (IEC and SI). Examples: "1024", "1KiB", "2.5MB", "1G".

func ParseBytesUint added in v1.5.0

func ParseBytesUint(s string) (uint64, error)

ParseBytesUint parses a string representation of bytes into a uint64. It supports both pure numbers and size suffixes (IEC and SI). Uses big.Int arithmetic for precision with large values.

Types

type FieldError

type FieldError struct {
	Path    string // e.g., "Database.Port"
	Tag     string // e.g., "env", "default"
	Value   string // the invalid value
	Message string
	Err     error
}

FieldError represents an error that occurred while processing a specific field.

func (*FieldError) Error

func (e *FieldError) Error() string

Error returns the string representation of the FieldError.

func (*FieldError) Unwrap

func (e *FieldError) Unwrap() error

Unwrap returns the underlying error.

type LoadError

type LoadError struct {
	Source string // file path or source name
	Errors []FieldError
}

LoadError represents an error that occurred during the configuration loading process.

func (*LoadError) Error

func (e *LoadError) Error() string

Error returns the string representation of the LoadError.

type Scanner

type Scanner interface {
	// Scan assigns the value to the custom type.
	Scan(src any) error
}

Scanner is an interface for custom string-to-type conversion.

type Setter

type Setter interface {
	// SetDefaults sets default values for the struct.
	SetDefaults()
}

Setter is an interface for setting default values. Only pointer receivers should implement this interface.

type ValidationError

type ValidationError struct {
	Errors []error
}

ValidationError wraps validation errors from the validator package.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error returns the string representation of the ValidationError.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap returns the first error in the list.

Jump to

Keyboard shortcuts

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