From bbc1758fb34f329428482f8a721d7dc6192837b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Tue, 22 Oct 2024 22:55:46 +0200 Subject: [PATCH] CodeReviewComments: avoid using naked returns --- CodeReviewComments.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CodeReviewComments.md b/CodeReviewComments.md index d0356df9..d0fd88e7 100644 --- a/CodeReviewComments.md +++ b/CodeReviewComments.md @@ -464,10 +464,9 @@ is less clear than: func (f *Foo) Location() (lat, long float64, err error) ``` -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. +Avoid using naked returns. Corollary: do not 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. Finally, in some cases you need to name a result parameter in order to change it in a deferred closure. That is always OK.