Created
July 14, 2019 00:06
-
-
Save cmelgarejo/8479904f9162242561ccda2851ddf88c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils | |
import ( | |
"log" | |
"os" | |
"strconv" | |
) | |
// MustGet will return the env or panic if it is not present | |
func MustGet(k string) string { | |
v := os.Getenv(k) | |
if v == "" { | |
log.Panicln("ENV missing, key: " + k) | |
} | |
return v | |
} | |
// MustGetBool will return the env as boolean or panic if it is not present | |
func MustGetBool(k string) bool { | |
v := os.Getenv(k) | |
if v == "" { | |
log.Panicln("ENV missing, key: " + k) | |
} | |
b, err := strconv.ParseBool(v) | |
if err != nil { | |
log.Panicln("ENV err: [" + k + "]\n" + err.Error()) | |
} | |
return b | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment