Yes. They are equal.

According to the go language spec:


   - Struct values are comparable if all their fields are comparable. Two
   struct values are equal if their corresponding non-blank
   <https://golang.org/ref/spec#Blank_identifier> fields are equal.

You can go through that part of the spec for greater understanding of the
equality operator.

https://golang.org/ref/spec#Comparison_operators


Ragards,

Uzondu


On Fri, Nov 23, 2018, 04:06 Youqi yu <yuyouqi101...@gmail.com wrote:

> type T {
>  Name string
> }
> a := &T{Name:"test"}
> b :=&T{Name:"test"}
> *a == *b
> Hi, all, I am beginner at golang, I have a question that when compare
> struct equality, I was told to use reflect.DeepEqual or make my own
> function. but the result of above code is true. Does it mean struct a
> equals struct b?
> thx.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to