env

package
v0.0.0-...-56d8f82 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package env provides a simple way to load environment variables into a struct.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Validator is the default validator used to validate the configuration.
	Validator = validator.New(validator.WithRequiredStructEnabled())
)

Functions

func Load

func Load[T any](paths ...string) (*T, error)

Load loads the environment configuration into a struct T.

By default if no paths are provided, it will look for a file called .env. If no file is found, it will simply ignore it.

Make sure to use the `env` tag from the github.com/caarlos0/env/v11 package, to specify the environment variable name.

The populated struct is validated using `Validator`.

func MustLoad

func MustLoad[T any](paths ...string) *T

MustLoad is like Load, but panics if an error occurs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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