envconfig

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 21 Imported by: 12

Documentation

Overview

Package envconfig loads configuration from env vars.

Package envconfig provides utilities for reading environment variables.

Package envconfig loads configuration from env vars.

Package envconfig loads configuration from env vars.

Package envconfig loads configuration from env vars.

Package envconfig loads configuration from env vars.

Package envconfig loads configuration from env vars.

Index

Constants

View Source
const (
	DefaultSecretsManagerPrefix = "aws-secretsmanager"
	DefaultParameterStorePrefix = "aws-parameterstore"
	DefaultS3Prefix             = "aws-s3"
	DefaultDynamoDbPrefix       = "aws-dynamodb"
	DefaultLambdaPrefix         = "aws-lambda"
	DefaultHTTPPrefix           = "#http"
)

Define default prefixes for Secrets Manager and Parameter Store.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

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

Env holds context information for loading confing from env vars.

func New

func New(opt Options) *Env

New creates a client for loading config from env vars.

func (*Env) Bool

func (e *Env) Bool(name string, defaultValue bool) bool

Bool extracts boolean value from env var. It returns the provided defaultValue if the env var is empty. The value returned is also recorded in logs.

func (*Env) Duration

func (e *Env) Duration(name string, defaultValue time.Duration) time.Duration

Duration extracts time.Duration value from env var. It returns the provided defaultValue if the env var is empty. The value returned is also recorded in logs.

func (*Env) Int

func (e *Env) Int(name string, defaultValue int) int

Int extracts int value from env var. It returns the provided defaultValue if the env var is empty. The value returned is also recorded in logs.

func (*Env) String

func (e *Env) String(name string, defaultValue string) string

String extracts string from env var. It returns the provided defaultValue if the env var is empty. The string returned is also recorded in logs.

type FuncPrintf

type FuncPrintf func(format string, v ...any)

FuncPrintf is a helper type for logging function.

type Options

type Options struct {
	AwsConfig            aws.Config
	Printf               FuncPrintf // defaults to log.Printf
	PrefixSecretsManager string     // defaults to "aws-secretsmanager"
	PrefixParameterStore string     // defaults to "aws-parameterstore"
	PrefixS3             string     // defaults to "aws-s3"
	PrefixDynamoDb       string     // defaults to "aws-dynamodb"
	PrefixLambda         string     // defaults to "aws-lambda"
	PrefixHTTP           string     // defaults to "#http"
	DisableQueryStore    bool
	CrashOnQueryError    bool
}

Options provide optional parameters for client.

Jump to

Keyboard shortcuts

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