all repos

test1 @ 3cc36e195be9b8468106cc37b604fe0d61ae7d02

for testing purposes
2 files changed, 19 insertions(+), 0 deletions(-)
docs(is, envy): add docs
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2025-12-19 17:48:47 +0200
Change ID: pxuprtvktourmuuunqpzrtwyqznkqvlu
Parent: 39836f8
M envy/env.go

@@ -1,3 +1,10 @@

+// Package envy provides type-safe environment variable access. +// +// It supports automatic conversion from string environment variables to common Go types: +// string, int, int64, float64, bool, and time.Duration. +// +// If an environment variable is not set or cannot be parsed, functions return the zero value +// of the requested type. package envy import (

@@ -6,6 +13,10 @@ "strconv"

"time" ) +// Get retrieves an environment variable and converts it to the specified type T. +// Supported types: string, int, int64, float64, bool, time.Duration. +// +// If the environment variable is not set or cannot be parsed, returns the zero value of T. func Get[T comparable](key string) T { var zero T val, ok := os.LookupEnv(key)

@@ -41,6 +52,8 @@ }

return res.(T) } +// GetOrDefault retrieves an environment variable, if not set, returns default value. +// Supported types: string, int, int64, float64, bool, time.Duration. func GetOrDefault[T comparable](key string, def T) T { var zero T if val := Get[T](key); val != zero {
M is/is.go

@@ -8,6 +8,7 @@ "strings"

"testing" ) +// Equal asserts that two values are equal. func Equal[T any](tb testing.TB, expected, got T) { tb.Helper()

@@ -16,6 +17,11 @@ tb.Errorf("expected: %#v, got: %#v", expected, got)

} } +// Err asserts error conditions with flexible expected values: +// - nil: asserts no error occurred +// - string: asserts error message contains the string +// - error: asserts errors.Is matches +// - reflect.Type: asserts errors.As succeeds func Err(tb testing.TB, got error, expected any) { tb.Helper()