Ilija Matoski

    ← Projects

    Maintained

    envwrap

    A lightweight Go package that simplifies environment variable management in tests.

    Language
    Go
    Started
    Last commit

    envwrap is a lightweight Go package that simplifies environment variable management in tests. It provides a clean way to set, override, and restore environment variables, ensuring that your tests don’t interfere with each other or leave behind unwanted state.

    • Isolated Environment Changes: Safely modify environment variables for tests without affecting other tests
    • Automatic Cleanup: All changes are automatically reverted when tests complete
    • Clean Environment Option: Start with a completely clean environment for maximum isolation
    • Simple API: Intuitive interface for setting environment variables

    Not for parallel tests: this package modifies global environment variables and is not suitable for parallel tests. Using it with t.Parallel() will lead to race conditions and unpredictable behavior.

    More information can be found on the GitHub repository.