You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
582 B

4 years ago
  1. package config
  2. import (
  3. "os"
  4. "strconv"
  5. )
  6. var MySqlHost = strEnv("LUCIFER_MYSQL_HOST")
  7. var MySqlPort = intEnv("LUCIFER_MYSQL_PORT")
  8. var MySqlUsername = strEnv("LUCIFER_MYSQL_USERNAME")
  9. var MySQlPassword = strEnv("LUCIFER_MYSQL_PASSWORD")
  10. var ServerPort = intEnv("LUCIFER_SERVER_PORT")
  11. func strEnv(key string) string {
  12. env, ok := os.LookupEnv(key)
  13. if !ok {
  14. panic("missing environment variable: " + key)
  15. }
  16. return env
  17. }
  18. func intEnv(key string) int {
  19. val, err := strconv.Atoi(strEnv(key))
  20. if err != nil {
  21. panic("invalid environment variable: " + key)
  22. }
  23. return val
  24. }