-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
back burneron hold for nowon hold for now
Description
I was just thinking that most of the types one might want to diff can already be compared for equality, as per the language spec.
So, we could add func Comparable(a, b interface{}) DiffWriteable
. It would ensure that both params are of the same type, that both are slice types, and that both element types are comparable.
For example, this would be useful with integers, arrays, custom struct types, et cetera.
I'd still keep Strings
, because for the foreseeable future, avoiding interface parameters will make the code faster and easier.
Potentially, we could also use the Equal
method as defined in https://github.com/google/go-cmp.
Metadata
Metadata
Assignees
Labels
back burneron hold for nowon hold for now
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]Add a Comparable helper?[/-][+]Add a Comparable helper[/+]josharian commentedon Aug 27, 2019
I have had a similar idea. Quoting from diff.go:
My only hesitation is that it expand the API, and the API already feels kinda large. Let's leave this one on the back burner for a bit until someone has a concrete need for it (I don't yet), since it is easy to add and hard to remove.
mvdan commentedon Aug 28, 2019
Sure!