SHARE
TWEET

Untitled

a guest Jul 16th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func GetEnvInt(label string, def ...interface{}) (res int) {
  2.     if v := os.Getenv(label); v != "" {
  3.         res, _ = strconv.Atoi(v)
  4.     } else {
  5.         res = 0
  6.     }
  7.     // convert interface{} to int
  8.     if len(def) > 0 {
  9.         res = def[0].(int)
  10.     }
  11.     return
  12. }
  13.  
  14. func GetEnvString(label string, def ...interface{}) (res string) {
  15.     res = os.Getenv(label)
  16.     if len(def) > 0 {
  17.         // convert interface{} to string
  18.         res = def[0].(string)
  19.     }
  20.     return
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top