variable

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 10

Documentation

Overview

Package variable exposes utilities for getting configuration from the environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBool

func GetBool(varName string) (bool, bool)

GetBool returns the boolean value of the environmental variable varName if the env var is empty or not a boolean it will return false, false.

func GetBytes

func GetBytes(varName string) (uint64, bool)

GetBytes returns the number of bytes represented by the environmental variable varName if the env var is empty or not a valid byte string it will return 0, false.

func GetDuration

func GetDuration(varName string) (time.Duration, bool)

GetDuration returns the time.Duration value of the environmental variable varName if the env var is empty or not a valid duration string it will return 0, false.

func GetDurationBC

func GetDurationBC(varName string) (time.Duration, bool)

GetDurationBC returns the time.Duration value of the environmental variable varName if the env var is empty or not a valid duration string it will return 0, false.

NOTE: This is the backwards compatible variant of 'GetDuration' meaning when failing to parse a duration, it will fallback to parsing an integer number of seconds.

func GetFloat64 added in v1.1.0

func GetFloat64(varName string) (float64, bool)

GetFloat64 returns the float64 value of the environmental variable varName if the env var is empty or not a valid.

func GetHTTPTimeouts

func GetHTTPTimeouts(envVar string, defaults netutil.HTTPTimeouts) (netutil.HTTPTimeouts, error)

GetHTTPTimeouts returns the timeouts that should be used for a HTTP client from the environment or uses provided default values.

NOTE: This function does not guarantee that every field of the returned netutil.HTTPTimeouts is going to be non-nil, instead this is ensured by netutil.NewHTTPTransport().

func GetInt

func GetInt(varName string) (int, bool)

GetInt returns the int value of the environmental variable varName if the env var is not an int or empty it will return 0, false.

func GetUint64

func GetUint64(varName string) (uint64, bool)

GetUint64 returns the uint64 value of the environmental variable varName if the env var is not an int or empty it will return 0, false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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