env

package
v0.0.0-...-a25ac86 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	UseDotEnv bool
}

Config is a struct that holds the configuration for the environment initialization process.

type Env

type Env struct {
	// See that the `env` tag is used to specify the name of the environment variable
	// and the `default` tag is used to specify a default value if the environment variable
	// is not set. If a default value is not provided and the environment variable is not set,
	// the application will panic.
	BaseUrl         string `env:"BASE_URL" default:"http://localhost:3000"`
	FromEmail       string `env:"FROM_EMAIL"`
	MjApiKeyPublic  string `env:"MJ_APIKEY_PUBLIC"`
	MjApiKeyPrivate string `env:"MJ_APIKEY_PRIVATE"`
}

Env is a struct that holds all the environment variables that the application needs. It's used to initialize the environment variables and provide a single source of truth for the application's configuration.

func (*Env) Init

func (e *Env) Init(c Config)

Try to load environment variables from a .env file (if UseDotEnv is true), panic if it fails. Attempt to find all environment variables based on the `env` tag and set the value of the field. If a value is empty and doesn't have a default tag, panic.

Jump to

Keyboard shortcuts

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