go-golden
Yet another Go package for working with *.golden test files,
with a focus on simplicity.
## Import
```go
import "github.com/jimeh/go-golden"
```
## Usage
```go
func TestExampleMyStruct(t *testing.T) {
got, err := json.Marshal(&MyStruct{Foo: "Bar"})
require.NoError(t, err)
if golden.Update() {
golden.Set(t, got)
}
want := golden.Get(t)
assert.Equal(t, want, got)
}
```
The above example will read/write to:
- `testdata/TestExampleMyStruct.golden`
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.
## Documentation
Please see the
[Go Reference](https://pkg.go.dev/github.com/jimeh/go-golden#section-documentation)
for documentation and examples.
## License
[MIT](https://github.com/jimeh/go-golden/blob/main/LICENSE)