I wonder, why composite literals are treated differently than structs, when it comes to methods.
As can be seen in the Playground Example, Go deals with an actual argument of a method call automatically:
- a pointer is de-referenced in case of value receiver
- a value’s address is calculated in case of a pointer receiver
With composite literals, its different:
- a pointer is de-referenced in case of value receiver (ok)
- a composite literal’s address is NOT automatically calculated in case of a pointer receiver (why not?)
When I explicitly take the composite literal’s address, it works.
Please help - I would really like to understand this.
(Please note, that I’m not considering interfaces here, where things are quite different)