mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
29 lines
492 B
Go
29 lines
492 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/joho/godotenv"
|
|
"github.com/labstack/gommon/log"
|
|
)
|
|
|
|
type Config map[string]string
|
|
|
|
var DefaultConfig = Config{
|
|
"PORT": "8000",
|
|
"DEBUG": "false",
|
|
}
|
|
|
|
func NewConfig() func(string) string {
|
|
_ = godotenv.Load()
|
|
log.Info("loaded env variables")
|
|
|
|
return func(key string) string {
|
|
if value := os.Getenv(key); value != "" {
|
|
return value
|
|
} else {
|
|
log.Warnf("no value found for %s using defaults", key)
|
|
return DefaultConfig[key]
|
|
}
|
|
}
|
|
}
|