config

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(name string, defaultValue bool) bool

Bool returns false if variable is not set or set to false, true otherwise

func CommitHash

func CommitHash() string

func DatabaseURL

func DatabaseURL() string

DatabaseURL returns value of DATABASE_URL if running in test mode returns TEST_DATABASE_URL

func Duration

func Duration(name string, defaultValue time.Duration) (time.Duration, error)

Duration parses the duration from the `name` environment variable. If the environment variable is not defined, it returns the given default value. It returns a duration or an error on parse error.

func Float

func Float(name string, defaultValue float64) float64

Float returns config for this key as float64 or default value

func GetListen

func GetListen(defaultPort string) (string, string)

GetListen returns :8080 and 8080 for ListenAddr and Port from PORT env var

func GetListenByName

func GetListenByName(key string, defaultPort string) (string, string)

GetListenByName returns :8080 and 8080 for ListenAddr and Port, from key env var

func Int

func Int(name string, defaultValue int) int

Int returns config for this key as int or default value

func Int64 added in v1.6.1

func Int64(name string, defaultValue int64) int64

func RedisURL

func RedisURL() string

RedisURL returns value of REDIS_URL if running in test mode returns TEST_REDIS_URL

func SentryDSN

func SentryDSN() string

SentryDSN returns the Sentry DSN (https://docs.sentry.io/quickstart/#configure-the-dsn) from an environment variable

func SetPrefix

func SetPrefix(name string)

SetPrefix sets environment variables prefix during development

func String

func String(name, defaultValue string) string

String returns config for this key or default value

func StringEnv

func StringEnv(name, defaultValue string, env GoEnv) string

StringEnv fetches from TEST_<var> if running in test mode

func TracingSampleRate

func TracingSampleRate(defaultValue float64) float64

TracingSampleRate parses the TRACING_SAMPLE_RATE environment variable value to a float.

func Uint added in v1.6.1

func Uint(name string, defaultValue uint) uint

func Uint64 added in v1.6.1

func Uint64(name string, defaultValue uint64) uint64

func ZipkinURL

func ZipkinURL() string

ZipkinURL returns the URL of the Zipkin collector endpoint

Types

type GoEnv

type GoEnv struct {
	Name        string
	Development bool
	Test        bool
	Staging     bool
	Production  bool
}

GoEnv keeps go environment

func FetchGoEnv

func FetchGoEnv() GoEnv

FetchGoEnv returns go struct

Jump to

Keyboard shortcuts

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