-
I have my .env file with 2 properties
when I
What am I doing wrong? package main
import (
"fmt"
"github.com/caarlos0/env/v6"
)
type config struct {
BotToken string `env:"BOT_TOKEN,notEmpty"`
Test int32 `env:"TEST"`
}
func main() {
cfg := config{}
if err := env.Parse(&cfg); err != nil {
fmt.Printf("%+v\n", err)
}
fmt.Printf("%+v\n", cfg)
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
This lib does not handle |
Beta Was this translation helpful? Give feedback.
-
Hey! Just found this discussion and the same happened to me, when reading the readme gives the impression that it is going to take the vars directly from your .env file. I'm new in Go, and I figured it out because other coworker told me I need to load the .env with other pckg. |
Beta Was this translation helpful? Give feedback.
-
I've also ran into this problem xD. You, guys, can use github.com/joho/godotenv (or its autoload) module together with this one. type Config struct { func main() { |
Beta Was this translation helpful? Give feedback.
This lib does not handle
.env
files. It only parses environment variables to an user-defined struct.