Skip to content

Instantly share code, notes, and snippets.

@kanzitelli
Last active August 28, 2019 15:32
Show Gist options
  • Save kanzitelli/115c55b652879bea19b13b168d10b9f6 to your computer and use it in GitHub Desktop.
Save kanzitelli/115c55b652879bea19b13b168d10b9f6 to your computer and use it in GitHub Desktop.
utils/utils.go #1 - 📰Good News app. Golang backend behind Traefik reverse proxy with https available.
package utils
import (
"log"
"github.com/kelseyhightower/envconfig"
)
// EnvVariables <struct>
// is used to descrive environment variables structure of a project
type EnvVariables struct {
DebugMode bool
}
var variables *EnvVariables
// InitEnvVars <function>
// is used to initialize environment variables of a project
func InitEnvVars() {
variables = new(EnvVariables)
err := envconfig.Process("api", variables)
if err != nil {
log.Fatal(err)
}
}
// GetEnvVars <function>
// is used to return current environment variables
func GetEnvVars() *EnvVariables {
return variables
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment