与reflect.TypeOf一起使用的空结构

Whats the difference between &Duck{} and (*Duck)(nil)? Is there any reason to prefer one over the other?

ex:

    fmt.Println(reflect.TypeOf(&Duck{}) == reflect.TypeOf((*Duck)(nil)))//true
    fmt.Println(nil == (*Duck)(nil))//true
    fmt.Println(nil == &Duck{})//false

&Duck{} points to a "Zero" struct instance, but it is most certainly not nil! You can assign values to it. You can't do all that to a nil pointer, regardless of the fact that they have the same type.

If you're just interested in checking types, I suppose a nil pointer is more efficient as there are no allocations of objects involved.

So it comes down to what exactly it is you want to do.