go-test / deep

Golang deep variable equality test that returns human-readable differences
MIT License
743 stars 54 forks source link

Confusing diff when comparing distinct types with the same name #39

Closed frekui closed 3 years ago

frekui commented 4 years ago

I'm using v1.0.4.

This program:

package main

import (
    "fmt"

    "github.com/go-test/deep"
    v6 "github.com/olivere/elastic"
    v7 "github.com/olivere/elastic/v7"
)

func main() {
    errv6 := v6.Error{}
    errv7 := v7.Error{}

    fmt.Printf("diff: %v\n", deep.Equal(errv6, errv7))
}

produces the output diff: [elastic.Error != elastic.Error] which gives little indication for why there is a difference between errv6 and errv7. I have used github.com/olivere/elastic here but the problem is not specific to that module. Perhaps the full import path can be included in the diff if two distinct types have the same name?

daniel-nichter commented 3 years ago

Done in https://github.com/go-test/deep/pull/44. Now if the type names are the same, it'll prepend the full pkg path name:

github.com/go-test/deep/test/v1.Error != github.com/go-test/deep/test/v2.Error"

Will release as v1.0.7.