On Sat, Aug 26, 2023 at 6:02 PM Mike Schinkel <m...@newclarity.net> wrote:

> OTOH, in my quest to provide the simplest example I could, I provided an
> example that does not expose the use-case I was interested in exploring,
> unfortunately.
>
> Let me instead present some real code from my current project,
> specifically the variable declarations on the lines 35-36 of the
> `Process()` method of `*FileProcessor` where the variables declared at the
> top are not referenced after the label:
>
>
> https://github.com/newclarity/wpfr/blob/88d1289a90646f59ec4233eed0e421f1eae36332/pkg/wpfr.go#L34-L75
>
>
Is the code after the "end" label ever going to be more complicated than a
simple "return err"? If not then I don't see the point of the goto
statements. Also, since you named the return value you can simply do
"return" rather than "return err" (personally I'm not a fan of bare returns
that implicitly return the named return parameters). That function can be
ten lines (25%) shorter and I would argue would be clearer since the reader
doesn't have to look at what follows the "end" label.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD-%3D-nWm917Mujx6spwPwOPwy-Su8AvCr2bATB-2t8Wcsg%40mail.gmail.com.

Reply via email to