This is an internalized and modernized copy of github.com/davecgh/go-spew, a deep pretty printer for Go data structures.
Source repository: github.com/davecgh/go-spew
Original license: ISC License (see LICENSE)
Copyright: 2012-2016 Dave Collins
go-spew implements a deep pretty printer for Go data structures to aid in debugging, providing features like pointer dereferencing, circular reference detection, custom Stringer/error interface handling, and hexdump-style byte array output.
This fork of testify maintains zero external dependencies for its core assertion packages. By internalizing go-spew, we eliminate the external dependency while gaining full control over the code to apply modernizations aligned with our go1.24 target.
This internalized copy has been modernized from the original go-spew codebase with the following changes:
- Type aliases: Replaced
interface{}withanythroughout - Modern build tags: Updated from
// +buildto//go:buildformat - Range iteration: Used
for i := range ninstead offor i := 0; i < n; i++ - reflect.TypeFor: Replaced
reflect.TypeOf(T(0))withreflect.TypeFor[T]() - Standard library improvements: Used
strings.ReplaceAll()instead ofstrings.Replace(..., -1)
- Linting compliance: Added linting directives (
//nolint) with explanations where appropriate - Test improvements: Added
t.Helper()calls in test helper functions - Modern idioms: Used
slices.Contains()instead of manual loops - String building: Used
strings.Builderfor efficient string concatenation - Code organization: Improved struct field ordering and switch statement structure with explicit
fallthroughcomments
- Markdown formatting: Updated godoc documentation comments to use modern markdown headings (
#) and list formats (-) - Comment punctuation: Standardized comment punctuation and formatting
- Clarity improvements: Fixed typos and improved readability
- Test data relocation: Moved
testdata/totestsrc/with proper documentation
The internalized copy maintains API compatibility with the original while incorporating targeted improvements:
- Deterministic map sorting: The
SpewKeysconfiguration option enables sorted map key output for consistent diffs (relevant for testify's assertion output)- Additional optimizations for deterministic diff generation (
stretchr/testify#1822)
- Additional optimizations for deterministic diff generation (
- time.Time rendering: Enhanced handling of
time.Timevalues in nested structures (applied fromstretchr/testify#1829) - panic/hang Reinforced input checking to avoid edge cases
- Proper fix for panic on unexported struct keys in maps (
stretchr/testify#1816) - Fix for circular map references (runtime stack overflow)
- Proper fix for panic on unexported struct keys in maps (
The linting effort is still going on...
This internalized copy is maintained as part of github.com/go-openapi/testify/v2 and follows the same Go version requirements (currently go1.24). It does not track upstream go-spew releases, as it has diverged through modernization.
For issues or improvements specific to this internalized version, please file issues at: https://github.com/go-openapi/testify/issues
This code retains its original ISC License. See LICENSE for the full license text.
The original copyright and license terms are preserved in accordance with the ISC License requirements.