config

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 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 added in v0.1.9

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

Parser parses the config provided through environment variables.

func New added in v0.1.9

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 added in v0.1.9

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

EnvBool extracts a boolean environment variable.

func (Parser) EnvFloat added in v0.1.9

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

EnvFloat extracts a float environment variable.

func (Parser) EnvInt added in v0.1.9

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

EnvInt extracts an integer environment variable.

func (Parser) EnvStr added in v0.1.9

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

EnvStr extracts a string environment variable.

func (Parser) EnvStrArray added in v0.1.9

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