genv

package
v0.0.0-...-04777cf Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

The above code is a Go package that provides functions for retrieving environment variables with type conversion and fallback values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Env

func Env[T EnvValueType](key string, fallback T) T

The `Env` function retrieves the value of an environment variable and provides a fallback value if the variable is not set.

func EnvWithConverter

func EnvWithConverter[T EnvValueType](key string, converter EnvConverter[T]) T

The function `EnvWithConverter` retrieves an environment variable value and converts it to a specified type using a provided converter function.

Types

type EnvConverter

type EnvConverter[T any] func(string, bool) T

type EnvValueType

type EnvValueType interface {
	IntType | UintType | FloatType | ~bool | ~string | time.Time
}

The type EnvValueType represents a value that can be an integer, unsigned integer, floating-point number, boolean, string, or time.

type FloatType

type FloatType interface {
	~float32 | ~float64
}

The FloatType interface represents either a float32 or a float64 type.

type IntType

type IntType interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

The above type defines an interface that can be implemented by any integer type in Go.

type UintType

type UintType interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

The above type defines an interface that can be implemented by any unsigned integer type in Go.

Jump to

Keyboard shortcuts

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