env

package module
v1.0.0 Latest Latest
Warning

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

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

README

env

Minimal Go library for loading environment variables with type safety.

Features

  • Generic-based API
  • Supports all primitives: string, bool, int*, uint*, float32, float64
  • Default values
  • Custom parsers via Parser[T] interface
  • Typed errors

Examples

See the examples

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissing              = errors.New("missing")
	ErrParserNotImplemented = errors.New("parser not implemented")
)

Functions

func Load

func Load[T any](key string, defaultValue ...T) (result T, err error)

func LoadWithErr

func LoadWithErr[T any](key string, err *error, defaultValue ...T) T

Types

type Parser

type Parser interface {
	FromString(s string) error
}

Directories

Path Synopsis
examples
basic command
custom_parser command
default_values command
error_handling command
load_multiple command

Jump to

Keyboard shortcuts

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