Don't go too crazy with named returns. I would not use them just to
avoid declaring a variable in the body of the function. As the code
review comments wiki page[0] says:
"Naked returns are okay if the function is a handful of lines. Once
it's a medium-sized function, be explicit with your return values.
Corollary: it's not worth it to name result parameters just because it
enables you to use naked returns. Clarity of docs is always more
important than saving a line or two in your function."
Also: it's fine to initialize slices as nil if you're going to be
appending to them:
var result []int
for ... {
result = append(result, ...)
}
[0]
https://code.google.com/p/go-wiki/wiki/CodeReviewComments#Named_Result_Parameters
> --
> 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...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.