.env file support?
lordvidex opened this issue · comments
Owamoyo Evans commented
With this package, is it possible to load .env files?
Cemre Mengu commented
No AFAIK but you can use it with godotenv. Something like:
package config
import (
"github.com/caarlos0/env/v8"
_ "github.com/joho/godotenv/autoload"
)
type Config struct {
DatabaseUrl string `env:"DATABASE_URL"`
Host string `env:"HOST"`
Port string `env:"PORT"`
}
func New() *Config {
var cfg Config
env.Parse(&cfg)
return &cfg
}