dotenv-validator
dotenv-validator
is a simple package that validates your environment based upon a formatted .env.sample
file. Based upon dotenv_validator from FastRuby.io.
Usage
Installation
go get github.com/duffn/dotenv-validator
Configuring your environment variables
Tell dotenv-validator
how you expect your environment variables by commenting them in your .env.sample
file.
VAR1=testing # required
VAR2=123 # format=int
VAR3=notrequired
VAR4=bob@bobloblaw.com # required,format=email
.env.sample
VAR1=bob # required
VAR2=lobloaw # required,format=str
VAR3=1.3415 # format=float
VAR4=ABCDEF # format=[A-Z]+
VAR5=notrequired
Running
package main
import (
"fmt"
validator "github.com/duffn/dotenv-validator"
)
func main() {
err := validator.Validate()
fmt.Println(err)
}
Choose your sample file.
package main
import (
"fmt"
validator "github.com/duffn/dotenv-validator"
)
func main() {
err := validator.ValidateWithFilename("env_sample")
fmt.Println(err)
}
License
MIT