| ▲ | masklinn 3 hours ago | |
> I would think that the returned value would be: `(nil, return-value-of-Decode-call)`. `user` is typed as a struct, so it's always going to be a struct in the output, it can't be nil (it would have to be `*User`). And Decoder.Decode mutates the parameter in place. Named return values essentially create locals for you. And since the function does not use naked returns, it's essentially saving space (and adding some documentation in some cases though here the value is nil) for this:
https://godbolt.org/z/8Yv49Yvr5However Go's named return values are definitely weird and spooky:
returns 2, not 1. | ||