Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pavleprica committed Nov 8, 2022
1 parent 4cabe9e commit e6c219b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions conf/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var (
notParsableErrorMessage = "variable not parsable"
)

// GetEnv returns a string value of the environment variable name provided.
// It returns an error in the event of the variable not existing.
func GetEnv(variableName string) (string, error) {
variable := os.Getenv(variableName)

Expand All @@ -21,6 +23,8 @@ func GetEnv(variableName string) (string, error) {
return variable, nil
}

// GetEnvOrDefault returns a string value of the environment variable name provided.
// In case there is an error, or the variable doesn't exist, it will return the default provided value.
func GetEnvOrDefault(variableName string, defaultValue string) string {
variable := os.Getenv(variableName)

Expand All @@ -30,6 +34,8 @@ func GetEnvOrDefault(variableName string, defaultValue string) string {
return variable
}

// GetEnvInt returns an int value of the environment variable name provided.
// It returns an error in the event of the variable not existing or parsing error.
func GetEnvInt(variableName string) (int, error) {
variable := os.Getenv(variableName)

Expand All @@ -46,6 +52,8 @@ func GetEnvInt(variableName string) (int, error) {
return intVariable, nil
}

// GetEnvIntOrDefault returns an int value of the environment variable name provided.
// In case there is an error, or the variable doesn't exist, it will return the default provided value.
func GetEnvIntOrDefault(variableName string, defaultValue int) int {
variable := os.Getenv(variableName)

Expand All @@ -62,6 +70,8 @@ func GetEnvIntOrDefault(variableName string, defaultValue int) int {
return intVariable
}

// GetEnvBool returns a bool value of the environment variable name provided.
// It returns an error in the event of the variable not existing or parsing error.
func GetEnvBool(variableName string) (bool, error) {
variable := os.Getenv(variableName)

Expand All @@ -78,6 +88,8 @@ func GetEnvBool(variableName string) (bool, error) {
return boolVariable, nil
}

// GetEnvBoolOrDefault returns a bool value of the environment variable name provided.
// In case there is an error, or the variable doesn't exist, it will return the default provided value.
func GetEnvBoolOrDefault(variableName string, defaultValue bool) bool {
variable := os.Getenv(variableName)

Expand Down

0 comments on commit e6c219b

Please sign in to comment.