dotenv

command module
v0.0.0-...-67bb498 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 15 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL