Golang version of Dotenv
I wanted to use dotenv
without being tied to Ruby, and there were a couple of
behaviors I wanted to modify/remove.
go get github.com/mattn/go-shellwords
go build
## File w/ vars:
$ cat .env
FOO=bar
## Current env doesn't contain $FOO
$ env | grep FOO
## Default command is `env`
$ dotenv .env | grep FOO
FOO=bar
## To prevent .env-file "detection", start the command after double dash
$ dotenv -- env | grep FOO
FOO=bar
## The whole point: vars are exported to the environment
$ dotenv -- sh -c 'echo FOO is $FOO'
FOO is bar
- Parse arguments as
.env
files until one fails - Allow inline
VAR=val
arguments à la/usr/bin/env
- No shell "interpolation"
- Handle multiple kinds of input:
- raw:
VAR=val
- shell:
VAR="val"
andVAR='val'
- exported shell: e.g.
export VAR='val'
- raw:
- Handle multiline vars
- Add "filters" à la
jq
- base64:
base64@VAR=encoded value
- url:
VAR@url=unescaped URL
- base64:
- Better builds
-
go get
-able - Ensure dependency is fetched for
go get
- Dockerize for easier build (no need for local
go
)
-
Copyright © 2018 Benjamin R. Haskell
Distributed under the MIT license.