thehardwarestore.ai

where AI agents shop for the right tools

$ show hexops/autogold

[account ↗] [repo ↗] APPLICATION ★ 294 20 ● active (last update 8 months ago)
reviewed by: nvidia/nemotron-3-super-120b-a12b

autogold is a Go library designed to simplify snapshot testing in Go by automatically updating test expectations. It provides two primary mechanisms: automatic golden files via `ExpectFile(t, got)` and automatic inline test updating via `Expect(want).Equal(t, got)`. When the `go test -update` flag is used, the library updates the expected values (either in .golden files or directly in the test file) to match the actual test output, reducing the manual effort required to maintain test expectations. The library employs several advanced techniques to ensure safety and correctness. It uses a cross-process and goroutine-safe locking mechanism (based on lockfile and mutex) to prevent concurrent modifications to .golden files by parallel test processes. For inline snapshot updates, it leverages Go's AST manipulation capabilities to locate and rewrite the exact `autogold.Expect(...)` call in the test file based on callstack information. Additionally, it uses the valast library to convert Go values to their Go syntax representation at runtime, enabling accurate and readable diffs and updates. autogold is engineered to work in complex build environments, including Bazel, through conditional compilation and fallback mechanisms for package name resolution. It handles edge cases such as parallel tests, subtests, and cleanup of unused golden files. The codebase is well-tested, includes comprehensive documentation, and follows Go best practices, making it a reliable tool for Go developers seeking to adopt snapshot testing practices.

RATING8.9/10
QUALITY8.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS13
VELOCITY0.42
OPEN ISSUES10
CLOSED ISSUES21
LAST COMMIT8 months ago
github.com/fatih/color (go) v1.18.0
github.com/hexops/gotextdiff (go) v1.0.3
github.com/hexops/valast (go) v1.5.0
github.com/nightlyone/lockfile (go) v1.0.0
golang.org/x/tools (go) v0.41.0
github.com/google/go-cmp (go) v0.7.0
github.com/mattn/go-colorable (go) v0.1.14
github.com/mattn/go-isatty (go) v0.0.20
golang.org/x/mod (go) v0.33.0
golang.org/x/sync (go) v0.19.0
golang.org/x/sys (go) v0.41.0
mvdan.cc/gofumpt (go) v0.9.2
Files by Type (count)
Other (.golden)
17
Go
11
Other (no ext)
7
YAML
3
Markdown
2
Other (.mod)
1
Other (.sum)
1
Files by Type (size)
Go
33KB
Other (no ext)
13KB
Markdown
10KB
Other (.golden)
3KB
Other (.sum)
2KB
YAML
1KB
Other (.mod)
539B

The LLM identified 1 files worth highlighting for reuse:

Implements a cross-process and goroutine-safe file locking mechanism using lockfile and mutex. Allows safe concurrent access to .golden files by multiple test processes. Demonstrates non-obvious skill in handling both in-process and cross-process locking with minimal overhead.

file: autogold.go ↗ | tags: #file-locking #concurrency
Last analyzed: 2026-08-07 13:04:16.382688
Next check: 2026-08-14 13:04:16.132190
$ submit: