config

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config provides functions which can be used to extract environment variables and parse them to the right type.

Index

Constants

View Source
const (
	// ProdEnv can be used as value when reading out the type of environment.
	ProdEnv string = "production"
	// TestEnv can be used as value when reading out the type of environment.
	TestEnv string = "test"
	// DevEnv can be used as value when reading out the type of environment.
	DevEnv string = "development"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser parses the config provided through environment variables.

func New

func New(logger *slog.Logger) Parser

New returns a new Parser and loads environment variables that could be provided using a .env file (particularly useful during development).

func (Parser) EnvBool

func (c Parser) EnvBool(key string, defaultValue bool) bool

EnvBool extracts a boolean environment variable.

func (Parser) EnvFloat

func (c Parser) EnvFloat(key string, defaultValue float64) float64

EnvFloat extracts a float environment variable.

func (Parser) EnvInt

func (c Parser) EnvInt(key string, defaultValue int) int

EnvInt extracts an integer environment variable.

func (Parser) EnvStr

func (c Parser) EnvStr(key string, defaultValue string) string

EnvStr extracts a string environment variable.

func (Parser) EnvStrArray

func (c Parser) EnvStrArray(key string, defaultValue []string) []string

EnvStrArray extracts a string array environment variable. The values should be separated by ','.

Jump to

Keyboard shortcuts

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