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:
parent
6371d5136f
commit
07e67d4684
2 changed files with 2 additions and 9 deletions
|
|
@ -4,7 +4,6 @@ Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/hculpan/areweplaying/cmd/cli/cmd"
|
||||
|
|
@ -13,10 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
godotenv.Load()
|
||||
|
||||
logFile := os.Getenv("CLI_LOG_FILE")
|
||||
if len(logFile) > 0 {
|
||||
|
|
|
|||
|
|
@ -37,10 +37,7 @@ func NewConfigFromEnv() (*Config, error) {
|
|||
var fetchServer string
|
||||
var sendServer string
|
||||
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error loading .env file: %s", err)
|
||||
}
|
||||
godotenv.Load()
|
||||
|
||||
username = os.Getenv("EMAIL_USERNAME")
|
||||
password = os.Getenv("EMAIL_PASSWORD")
|
||||
|
|
|
|||
Loading…
Reference in a new issue