Go has a builtin way to set and cleanup an ENV at the end of the test, restoring previous ENV if set

func TestMyFunc(t *testing.T) {
t.Setenv("MY_ENV", "value")
}

from `testing.T.Setenv` documentation:

Setenv calls os.Setenv(key, value) and uses Cleanup to restore the environment variable to its original value after the test.

This cannot be used in parallel tests.

--

--

Photo by danilo.alvesd on Unsplash

The activities you engage in, the people you interact with, and the bad habits you develop drain your energy.

The activities, people, and habits you follow can give you more energy than you had before.

Every decision you make plays a role in a domino effect, so take note of your daily choices. You can regain energy through these or be completely drained by them.

--

--