윤준석

ADD: joongna service config

hide secret in .env file
...@@ -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
......
1 +# Secret Configuration
2 +SECRET.CLIENTID=
3 +SECRET.CLIENTSECRET=
...\ No newline at end of file ...\ No newline at end of file
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 +}
1 +module joongna
2 +
3 +go 1.17
4 +
5 +require (
6 + github.com/caarlos0/env/v6 v6.9.1 // indirect
7 + github.com/joho/godotenv v1.4.0 // indirect
8 +)
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=
1 +package main
2 +
3 +func main() {
4 +}