Yet another Go package for working with *.golden test files, with a focus on simplicity.

go-golden

Yet another Go package for working with *.golden test files, with a focus on simplicity.

Go Reference Actions Status Coverage GitHub issues GitHub pull requests License Status

Import

import "github.com/jimeh/go-golden"

Usage

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 for documentation and examples.

License

MIT

Owner
Jim Myhrberg
I'm a software engineering mercenary, who plays with code, video games, and on occasion, design.
Jim Myhrberg
Similar Resources

app-services-go-linter plugin analyze source tree of Go files and validates the availability of i18n strings in *.toml files

app-services-go-linter app-services-go-linter plugin analyze source tree of Go files and validates the availability of i18n strings in *.toml files. A

Nov 29, 2021

noioutil finds files using the "io/ioutil" package.

noioutil noioutil finds files using the "io/ioutil" package.

Dec 28, 2021

Go package for tail-ing files

Go package for tail-ing files A Go package striving to emulate the features of the BSD tail program. t, err := tail.TailFile("/var/log/nginx.log", tai

Dec 8, 2021

Compute message digest for large files in Go

checksum test coverage Compute message digest, like MD5 and SHA256, in golang for potentially large files. Usage package main import ( "fmt" "githu

Dec 28, 2022

copy files for humans

Go-Decent-Copy go-decent-copy provides a copy file for humans Usage package main import "github.com/hugocarreira/go-decent-copy" func main() { e

Sep 26, 2022

Golang wrapper for Exiftool : extract as much metadata as possible (EXIF, ...) from files (pictures, pdf, office documents, ...)

go-exiftool go-exiftool is a golang library that wraps ExifTool. ExifTool's purpose is to extract as much metadata as possible (EXIF, IPTC, XMP, GPS,

Dec 28, 2022

Load GTFS files in golang

go-gtfs Load GTFS files in Go. The project is in maintenance mode. It is kept compatible with changes in the Go ecosystem but no new features will be

Dec 5, 2022

An implementation of the FileSystem interface for tar files.

TarFS A wrapper around tar.Reader. Implements the FileSystem interface for tar files. Adds an Open method, that enables reading of file according to i

Sep 26, 2022

QueryCSV enables you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to a CSV file

QueryCSV enables you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to a CSV file

QueryCSV enable you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to CSV file

Dec 22, 2021
Comments
  • refactor: get closer to

    refactor: get closer to "stable"

    This includes sanitizing golden file names to avoid characters and names which are invalid on some operating systems. So this should now work on Linux, macOS, and Window.

    Also populate readme, and configure coverage reports.

  • go-golden should support pretty-printed golden files

    go-golden should support pretty-printed golden files

    Hi jimeh, have you thought about supporting something like json.Indent for updated golden files? It would make them cleaner to read manually, which I think would be a nice thing to have.

    Excited about this library!

yet another rss reader
yet another rss reader

yarr yarr (yet another rss reader) is a web-based feed aggregator which can be used both as a desktop application and a personal self-hosted server. I

Dec 29, 2022
A Go filesystem package for working with files and directories

Stowage A Go filesystem package for working with files and directories, it features a simple API with support for the common files and directories ope

May 28, 2021
Fastzip is an opinionated Zip archiver and extractor with a focus on speed.

Fastzip is an opinionated Zip archiver and extractor with a focus on speed. Archiving and extraction of files and directories can only occur w

Dec 6, 2022
go tool for working with /etc/hosts files

hostsfile This library, and the associated command line binary, will help you manipulate your /etc/hosts file. Both the library and the binary will le

Dec 30, 2022
Utility for working with files and folders stored on Google Drive

skicka Utility for working with files and folders stored on Google Drive. Note: skicka is not an official Google product! Intro skicka makes it easy t

Nov 15, 2021
Recreate embedded filesystems from embed.FS type in current working directory.

rebed Recreate embedded filesystems from embed.FS type in current working directory. Expose the files you've embedded in your binary so users can see

Sep 27, 2022
A small tool for sending a single file to another machine

file-traveler A small tool for sending a single file to another machine. Build g

Dec 28, 2021
Split text files into gzip files with x lines

hakgzsplit split lines of text into multiple gzip files

Jun 21, 2022
Easily create Go files from stub files

go-stubs Easily create .go files from stub files in your projects. Usage go get github.com/nwby/go-stubs Create a stub file: package stubs type {{.Mo

Jan 27, 2022