From 9770ef9f21aa38bba32c342c300a0bc3999e2315 Mon Sep 17 00:00:00 2001 From: zomo Date: Mon, 5 Jan 2026 23:09:10 -0600 Subject: [PATCH] updated conf --- .env.example | 2 ++ util/conf.go | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 830b5c9..8cd880b 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,7 @@ CLIENT_ID= # Twitch Client ID # Required +CLIENT_SECRET= # Twitch Client Secret + # Required REDIR_URI= # Twitch OAuth Redirect URI # Required diff --git a/util/conf.go b/util/conf.go index 36e4ac0..59ed491 100644 --- a/util/conf.go +++ b/util/conf.go @@ -10,22 +10,23 @@ import ( func LoadConfig() (*Config, error) { config := Config{} - + config.def() + err := config.loadEnv() if err != nil { return nil, err } // other sources? - config.def() config.verify() return &config, nil } type Config struct { - ClientID string - RedirectURI string - SQliteDB string + ClientID string + ClientSecret string + RedirectURI string + SQliteDB string } func (c *Config) def() { @@ -41,6 +42,9 @@ func (c *Config) loadEnv() error { if str, found := os.LookupEnv("CLIENT_ID"); found { c.ClientID = strings.TrimSpace(str) } + if str, found := os.LookupEnv("CLIENT_SECRET"); found { + c.ClientSecret = strings.TrimSpace(str) + } if str, found := os.LookupEnv("REDIR_URI"); found { c.RedirectURI = strings.TrimSpace(str) } @@ -55,6 +59,9 @@ func (c *Config) verify() error { if c.ClientID == "" { return errors.New("unable to load a configured Client ID") } + if c.ClientSecret == "" { + return errors.New("unable to load a configured Client Secret") + } if c.RedirectURI == "" { return errors.New("unable to load a configured Redirect URI") }