윤준석

ADD: joongna service config

hide secret in .env file
......@@ -276,4 +276,7 @@ dist
# Ignore code-workspaces
*.code-workspace
# Ignore .env file
.env
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,jetbrains
......
# Secret Configuration
SECRET.CLIENTID=
SECRET.CLIENTSECRET=
\ No newline at end of file
package config
import (
"log"
"github.com/caarlos0/env/v6"
"github.com/joho/godotenv"
)
type Config struct {
Secret struct {
CLIENTID string `env:"SECRET.CLIENTID"`
CLIENTSECRET string `env:"SECRET.CLIENTSECRET"`
}
}
var Cfg *Config
func init() {
err := godotenv.Load("./config/.env")
if err != nil {
log.Fatal("Load .env file failed.")
}
config := Config{}
if err := env.Parse(&config); err != nil {
log.Fatalf("%+v\n", err)
}
Cfg = &config
}
module joongna
go 1.17
require (
github.com/caarlos0/env/v6 v6.9.1 // indirect
github.com/joho/godotenv v1.4.0 // indirect
)
github.com/caarlos0/env/v6 v6.9.1 h1:zOkkjM0F6ltnQ5eBX6IPI41UP/KDGEK7rRPwGCNos8k=
github.com/caarlos0/env/v6 v6.9.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc=
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
package main
func main() {
}