Debian Codegraph @

/

0 files · 0 symbols
README (full)

envload

Restore environment variables, so you can break 'em

Build Status

GoDoc

SYNOPSIS

DESCRIPTION

Certain applications that require reloading of configuraiton from environment variables are sensitive to these values being changed.

Or maybe you are writing a test that wants to temporarily change the value of an environment variable, but you don't want it to linger afterwards.

In other languages this can be done with a "temporary" variable, like in Perl5:

use strict;
use 5.24;

sub foo {
  $ENV{IMPORTANT_VAR} = "foo";
  say $ENV{IMPORTANT_VAR}; # "foo"

  {
    local %ENV = %ENV; # inherit the original %ENV,
    $ENV{IMPORTANT_VAR} = "bar";
    say $ENV{IMPORTANT_VAR}; # "bar"
  }
  # 

  say $ENV{IMPORTANT_VAR}; # "bar"
}

This library basically allows you to do this in Go

dir debian/
file .gitignore
file .travis.yml
file LICENSE
file README.md
file env.go
file env_test.go
file example_test.go
file interface.go
file options.go