mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-03 15:56:22 +00:00
⚡ add .env.example file with configuration settings, refactor environment variable access methods
This commit is contained in:
@ -73,12 +73,12 @@ func (e *emailUtils) SendEmail(emailConfig *EmailConfig, target, subject, conten
|
||||
|
||||
func (e *emailUtils) GetEmailConfigFromEnv() *EmailConfig {
|
||||
return &EmailConfig{
|
||||
Enable: Env.GetenvAsBool("EMAIL_ENABLE", false),
|
||||
Enable: Env.GetAsBool("EMAIL_ENABLE", false),
|
||||
Username: Env.Get("EMAIL_USERNAME", ""),
|
||||
Address: Env.Get("EMAIL_ADDRESS", ""),
|
||||
Host: Env.Get("EMAIL_HOST", "smtp.example.com"),
|
||||
Port: Env.GetenvAsInt("EMAIL_PORT", 587),
|
||||
Port: Env.GetAsInt("EMAIL_PORT", 587),
|
||||
Password: Env.Get("EMAIL_PASSWORD", ""),
|
||||
SSL: Env.GetenvAsBool("EMAIL_SSL", true),
|
||||
SSL: Env.GetAsBool("EMAIL_SSL", true),
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ func (e *envUtils) Get(key string, defaultValue ...string) string {
|
||||
return value
|
||||
}
|
||||
|
||||
func (e *envUtils) GetenvAsInt(key string, defaultValue ...int) int {
|
||||
func (e *envUtils) GetAsInt(key string, defaultValue ...int) int {
|
||||
value := os.Getenv(key)
|
||||
if value == "" && len(defaultValue) > 0 {
|
||||
return defaultValue[0]
|
||||
@ -42,7 +42,7 @@ func (e *envUtils) GetenvAsInt(key string, defaultValue ...int) int {
|
||||
return intValue
|
||||
}
|
||||
|
||||
func (e *envUtils) GetenvAsBool(key string, defaultValue ...bool) bool {
|
||||
func (e *envUtils) GetAsBool(key string, defaultValue ...bool) bool {
|
||||
value := os.Getenv(key)
|
||||
if value == "" && len(defaultValue) > 0 {
|
||||
return defaultValue[0]
|
||||
|
Reference in New Issue
Block a user