Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement