Open Ndeta100 opened 2 months ago
Probably you have placed the .env
file in the wrong directory.
For an example, here is my file and folder structure:
│ .env
│ .env.test
│ go.mod
│ go.sum
│ readme.md
│
├───cmd
│ ├───api
│ │ main.go
I have used the godotenv.Load(file_path)
in the main.go
file. Here is my code:
godotenv.Load("../../.env")
I get this error when I build and publish my docker image then I try to pull and run it locally or on a vm with coolify. I have added my env as github secrets for the builf process but I still get the same error, even after adding the env variables to coolify. It suggested I neeet to comment out
godotenv.Load()
, but still same issue. Anyone can help?func init() { if err := godotenv.Load(); err != nil { log.Fatal(err) } }