by go-test

go-test / deep

Golang deep variable equality test that returns human-readable differences

496 Stars 34 Forks Last release: Not found MIT License 87 Commits 8 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Deep Variable Equality for Humans

Go Report Card Build Status Coverage Status GoDoc

This package provides a single function:

. It's like reflect.DeepEqual but much friendlier to humans (or any sentient being) for two reason:
  • deep.Equal
    returns a list of differences
  • deep.Equal
    does not compare unexported fields (by default)

is good (like all things Golang!), but it's a game of Hunt the Wumpus. For large maps, slices, and structs, finding the difference is difficult.

doesn't play games with you, it lists the differences:
package main_test

import ( "testing" "" )

type T struct { Name string Numbers []float64 }

func TestDeepEqual(t *testing.T) { // Can you spot the difference? t1 := T{ Name: "Isabella", Numbers: []float64{1.13459, 2.29343, 3.010100010}, } t2 := T{ Name: "Isabella", Numbers: []float64{1.13459, 2.29843, 3.010100010}, }

if diff := deep.Equal(t1, t2); diff != nil {


$ go test
--- FAIL: TestDeepEqual (0.00s)
        main_test.go:25: [Numbers.slice[1]: 2.29343 != 2.29843]

The difference is in

: the two values aren't equal using Go

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.