Make godotenv.Load() best-effort to support containerized deployments

A missing .env file no longer causes a fatal error. Env vars can now
come from the container environment (Docker/systemd) or a .env file
interchangeably.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Harry Culpan 2026-06-30 18:22:37 -04:00
parent 6371d5136f
commit 07e67d4684
2 changed files with 2 additions and 9 deletions

View file

@ -4,7 +4,6 @@ Copyright © 2024 NAME HERE <EMAIL ADDRESS>
package main package main
import ( import (
"log"
"os" "os"
"github.com/hculpan/areweplaying/cmd/cli/cmd" "github.com/hculpan/areweplaying/cmd/cli/cmd"
@ -13,10 +12,7 @@ import (
) )
func main() { func main() {
err := godotenv.Load() godotenv.Load()
if err != nil {
log.Fatal(err)
}
logFile := os.Getenv("CLI_LOG_FILE") logFile := os.Getenv("CLI_LOG_FILE")
if len(logFile) > 0 { if len(logFile) > 0 {

View file

@ -37,10 +37,7 @@ func NewConfigFromEnv() (*Config, error) {
var fetchServer string var fetchServer string
var sendServer string var sendServer string
err := godotenv.Load() godotenv.Load()
if err != nil {
return nil, fmt.Errorf("error loading .env file: %s", err)
}
username = os.Getenv("EMAIL_USERNAME") username = os.Getenv("EMAIL_USERNAME")
password = os.Getenv("EMAIL_PASSWORD") password = os.Getenv("EMAIL_PASSWORD")