google / go-cmp

Package for comparing Go values in tests
BSD 3-Clause "New" or "Revised" License
4.08k stars 209 forks source link

any over interface{} #330

Open mrwormhole opened 1 year ago

mrwormhole commented 1 year ago

the aim of this PR is to remove support for versions below 1.18 and complete existing TODO which encourages the use of any over interface{}

also Diff and Equal methods in compare.go are the most commonly used functions but due to confusion of "x" and "y", it causes new developers to write want and got in reverse, so I have renamed both Diff and Equal function signatures from

see if this makes sense @neild @dsnet

dsnet commented 1 year ago

I'm a 👎 to renaming got and want. See my comment here: https://github.com/google/go-cmp/issues/328#issuecomment-1518120671

I'm a 👍 for only supporting higher versions of Go and using any over interface{} if @neild is okay with it. In the past, Google needed older versions internally for a long time. I no longer work at Google, and so I'm perfectly happy support only the latest 2 versions.

neild commented 1 year ago

I'd rather wait until the x/ repos update to supporting only 1.18 before doing so here. (They're currently still on 1.17, although 1.17 is out of the supported window so they should be able to update at any time now.)

mrwormhole commented 1 year ago

ok I will rollback this to include only interface{} to any changes. It seems like a rabbit hole discussion about want/got so I will just follow the docs example. I left a comment to the issue why I think there are inconsistencies about which to put first (want,got) or (got, want). Then I will possibly wait for x repos