File: README.md

package info (click to toggle)
golang-github-lestrrat-go-envload 0.0~git20180220.a3eb8dd-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 92 kB
  • sloc: makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# envload

Restore environment variables, so you can break 'em

[![Build Status](https://travis-ci.org/lestrrat-go/envload.png?branch=master)](https://travis-ci.org/lestrrat-go/envload)

[![GoDoc](https://godoc.org/github.com/lestrrat-go/envload?status.svg)](https://godoc.org/github.com/lestrrat-go/envload)

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

```perl
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