You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing my Go web application, I realized that var arr1 []someStruct and arr2 := []someStruct{} are treated differently with reflect.DeepEqual(arr1, arr2). This is very misleading, since they're treated the same for single struct (not slices).
What did you expect to see?
I expected both slices of an empty struct to be exactly the same, so reflect.DeepEqual() => true.
What did you see instead?
As seen in the code, the var arr1 []someStruct and arr2 := []someStruct{} declarations behave differently in the reflect.DeepEqual() function.
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Here's the code: https://play.golang.org/p/yfTT4rvR4cb
When testing my Go web application, I realized that
var arr1 []someStruct
andarr2 := []someStruct{}
are treated differently withreflect.DeepEqual(arr1, arr2)
. This is very misleading, since they're treated the same for single struct (not slices).What did you expect to see?
I expected both slices of an empty struct to be exactly the same, so
reflect.DeepEqual()
=>true
.What did you see instead?
As seen in the code, the
var arr1 []someStruct
andarr2 := []someStruct{}
declarations behave differently in thereflect.DeepEqual()
function.The text was updated successfully, but these errors were encountered: