/
config.go
48 lines (41 loc) · 852 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package config
import (
"github.com/joho/godotenv"
"os"
)
type MailServiceConfig struct {
Host string
Port string
Username string
Password string
}
type SheetsConfig struct {
Credentials string
SheetID string
SheetName string
}
type Config struct {
Port string
DSN string
MailServiceConfig
SheetsConfig
}
func LoadConfig() (Config, error) {
godotenv.Load(".env")
cfg := Config{
Port: os.Getenv("PORT"),
DSN: os.Getenv("COCKROACH"),
MailServiceConfig: MailServiceConfig{
Host: os.Getenv("SMTP_HOST"),
Port: os.Getenv("SMTP_PORT"),
Username: os.Getenv("SMTP_USER"),
Password: os.Getenv("SMTP_PASS"),
},
SheetsConfig: SheetsConfig{
Credentials: os.Getenv("SHEET_CREDENTIALS"),
SheetID: os.Getenv("SHEET_ID"),
SheetName: os.Getenv("SHEET_NAME"),
},
}
return cfg, nil
}