Standard library / reflect
reflect.DeepEqual()
Recursively compare values of identical types. Nil and non-nil empty slices differ; non-nil functions are not deeply equal, and NaN has special equality behavior. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func DeepEqual(x, y any) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | any | Input value to compare or store, or numeric value to test for overflow. |
| y | any | Second input to compare. |
Return Value
bool
Whether the two values satisfy DeepEqual’s recursive comparison rules.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { fmt.Println(reflect.DeepEqual([]int{1, 2}, []int{1, 2}), reflect.DeepEqual([]int(nil), []int{}))}