Skip to content

Commit

Permalink
Equals supports go maps and slices
Browse files Browse the repository at this point in the history
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
  • Loading branch information
jfhamlin committed Jul 4, 2024
1 parent 5f656eb commit 38d1bdd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/lang/equal.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ func Equals(a, b any) bool {
}
return aVal.Pointer() == bVal.Pointer()
}
if aVal.Kind() == reflect.Map || bVal.Kind() == reflect.Map || aVal.Kind() == reflect.Slice || bVal.Kind() == reflect.Slice {
if aVal.Kind() != bVal.Kind() {
return false
}
return Equals(Seq(a), Seq(b))
}

if a == b {
return true
Expand Down

0 comments on commit 38d1bdd

Please sign in to comment.