github.com/jimeh/go-golden (go): Package golden is yet another package for working with *.golden test files, with a focus on simplicity through it's default behavior.  Golden file names are based on the name of the test function and any subtest names by calling t.Name(). File names are sanitized to ensure they're compatible with Linux, macOS and Windows systems regardless of what crazy characters might be in a subtest's name.  Typical usage should look something like this:  The above example will read/write to:  To update the golden file (have golden.Update() return true), simply set the GOLDEN_UPDATE environment variable to one of "1", "y", "t", "yes", "on", or "true" when running tests.  As the golden filename is based on t.Name(), it works with sub-tests too, ensuring each sub-test gets it's own golden file. For example:  The above example will read/write to:  The "P" suffixed methods, GetP(), SetP(), and FileP(), all take a name argument which allows using specific golden files within a given *testing.T instance.  The above example will read/write to:  This works with tabular tests too of course:  The above example will read/write to:
Keywords: go|go-golden|go-test|go-test-helper|go-testing|golang|golden-file