Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactoring how monolith loads .env #37

Merged
merged 1 commit into from
May 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions cmd/monolith/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ package main

import (
"fmt"
"log"

"github.com/ccil-kbw/robot/pkg/discord"
rec2 "github.com/ccil-kbw/robot/pkg/rec"

"go.uber.org/zap"
"os"
"os/signal"
"strings"
"time"

"go.uber.org/zap"

"github.com/joho/godotenv"
)

Expand Down Expand Up @@ -41,8 +44,11 @@ var (
stdMinutes = "4"
)

func init() {
loadEnvs()
}

func main() {
godotenv.Load()
msgs := make(chan string)
stop := make(chan os.Signal, 1)

Expand Down Expand Up @@ -131,3 +137,12 @@ func startServerWithRetry(host string, password string, data *rec2.RecordConfigD
}
}
}

func loadEnvs() {
err := godotenv.Load()
if err != nil {
log.Println(".env not present, using process envs and defaults")
} else {
log.Println(".env loaded")
}
}