env

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package env provides easy way to bind environment variables

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(s interface{}) (err error)

Bind binds environment variables into structure

func GetEnvAsArrayOfBoolOrFallback

func GetEnvAsArrayOfBoolOrFallback(key string, defaultValue []bool) (bools []bool, err error)

GetEnvAsArrayOfBoolOrFallback returns the env variable for the given key and falls back to the given defaultValue if not set

func GetEnvAsArrayOfFloat64OrFallback

func GetEnvAsArrayOfFloat64OrFallback(key string, defaultValue []float64) (floats []float64, err error)

GetEnvAsArrayOfFloat64OrFallback returns the env variable for the given key and falls back to the given defaultValue if not set

func GetEnvAsArrayOfIntsOrFallback

func GetEnvAsArrayOfIntsOrFallback(key string, defaultValue []int) (ints []int, err error)

GetEnvAsArrayOfIntsOrFallback returns the env variable for the given key and falls back to the given defaultValue if not set

func GetEnvAsArrayOfStringsOrFallback

func GetEnvAsArrayOfStringsOrFallback(key string, defaultValue []string) []string

GetEnvAsArrayOfStringsOrFallback returns the env variable for the given key and falls back to the given defaultValue if not set GetEnvAsArrayOfStringsOrFallback trims all whitespaces from input i.e. "us, fr, au" -> {"us","fr","au"}

func GetEnvAsBoolOrFallback

func GetEnvAsBoolOrFallback(key string, defaultValue bool) (val bool, err error)

GetEnvAsBoolOrFallback returns the env variable for the given key, parses it as boolean and falls back to the given defaultValue if not set

func GetEnvAsFloat64OrFallback

func GetEnvAsFloat64OrFallback(key string, defaultValue float64) (float64, error)

GetEnvAsFloat64OrFallback returns the env variable (parsed as float64) for the given key and falls back to the given defaultValue if not set

func GetEnvAsIntOrFallback

func GetEnvAsIntOrFallback(key string, defaultValue int) (int, error)

GetEnvAsIntOrFallback returns the env variable (parsed as integer) for the given key and falls back to the given defaultValue if not set

func GetEnvAsStringOrFallback

func GetEnvAsStringOrFallback(key, defaultValue string) string

GetEnvAsStringOrFallback returns the env variable for the given key and falls back to the given defaultValue if not set

Types

This section is empty.

Jump to

Keyboard shortcuts

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