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.

32 lines
758 B

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