Skip to content

benizi/dotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dotenv

Golang version of Dotenv

Introduction

I wanted to use dotenv without being tied to Ruby, and there were a couple of behaviors I wanted to modify/remove.

Compile

Local

go get github.com/mattn/go-shellwords
go build

Example

## 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

Features and TODOs

  • 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" and VAR='val'
    • exported shell: e.g. export VAR='val'
  • Handle multiline vars
  • Add "filters" à la jq
    • base64: base64@VAR=encoded value
    • url: VAR@url=unescaped URL
  • Better builds
    • go get-able
    • Ensure dependency is fetched for go get
    • Dockerize for easier build (no need for local go)

License

Copyright © 2018 Benjamin R. Haskell

Distributed under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages