Skip to content

go-zoox/dotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DotEnv

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Load application environment variables from a .env file into the current process.

// Usage 1: Type Safe Env Config
import (
  dotenv "github.com/go-zoox/dotenv"
)

type Config struct {
  Host string `env:"HOST" default:"0.0.0.0"`
  Port int    `env:"PORT" default:"8080"`
  DatabaseUrl string `env:"DATABASE_URL", required:"true"`
  Email string `env:"EMAIL"`
}

var config Config
if err := dotenv.Load(&config); err != nil {
  panic(err)
}
// Usage 2: Auto Load .env To OS
import (
  "os"
  
  _ "github.com/go-zoox/dotenv"
)

fmt.Println("env:", os.Get("FROM_DOT_ENV"))

Inspired by

About

Load application environment variables from a .env file into the current process.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages