Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func GetEnvInt(label string, def ...interface{}) (res int) {
- if v := os.Getenv(label); v != "" {
- res, _ = strconv.Atoi(v)
- } else {
- res = 0
- }
- // convert interface{} to int
- if len(def) > 0 {
- res = def[0].(int)
- }
- return
- }
- func GetEnvString(label string, def ...interface{}) (res string) {
- res = os.Getenv(label)
- if len(def) > 0 {
- // convert interface{} to string
- res = def[0].(string)
- }
- return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement