Showing
6 changed files
with
52 additions
and
0 deletions
... | @@ -276,4 +276,7 @@ dist | ... | @@ -276,4 +276,7 @@ dist |
276 | # Ignore code-workspaces | 276 | # Ignore code-workspaces |
277 | *.code-workspace | 277 | *.code-workspace |
278 | 278 | ||
279 | +# Ignore .env file | ||
280 | +.env | ||
281 | + | ||
279 | # End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,jetbrains | 282 | # End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,jetbrains | ... | ... |
joongna/config/.env_example
0 → 100644
joongna/config/config.go
0 → 100644
1 | +package config | ||
2 | + | ||
3 | +import ( | ||
4 | + "log" | ||
5 | + | ||
6 | + "github.com/caarlos0/env/v6" | ||
7 | + "github.com/joho/godotenv" | ||
8 | +) | ||
9 | + | ||
10 | +type Config struct { | ||
11 | + Secret struct { | ||
12 | + CLIENTID string `env:"SECRET.CLIENTID"` | ||
13 | + CLIENTSECRET string `env:"SECRET.CLIENTSECRET"` | ||
14 | + } | ||
15 | +} | ||
16 | + | ||
17 | +var Cfg *Config | ||
18 | + | ||
19 | +func init() { | ||
20 | + err := godotenv.Load("./config/.env") | ||
21 | + if err != nil { | ||
22 | + log.Fatal("Load .env file failed.") | ||
23 | + } | ||
24 | + | ||
25 | + config := Config{} | ||
26 | + if err := env.Parse(&config); err != nil { | ||
27 | + log.Fatalf("%+v\n", err) | ||
28 | + } | ||
29 | + Cfg = &config | ||
30 | +} |
joongna/go.mod
0 → 100644
joongna/go.sum
0 → 100644
1 | +github.com/caarlos0/env/v6 v6.9.1 h1:zOkkjM0F6ltnQ5eBX6IPI41UP/KDGEK7rRPwGCNos8k= | ||
2 | +github.com/caarlos0/env/v6 v6.9.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= | ||
3 | +github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= | ||
4 | +github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= |
joongna/main.go
0 → 100644
-
Please register or login to post a comment