I think that this is a good question. I do question whether your code 
examples are more or less simple when they are a single line. I'm worried 
they may be more compact, which hurts the readability, while still 
retaining the same complexity.

Being that you should be running `gofmt` before commiting, isn't this a bit 
of a non-issue? You can write a single line, and then `gofmt` will take 
care of the rest for you. You can use the brevity when you're developing, 
but gain the readability again after `gofmt` works its magic.

To explain further, I find that multi-line if-blocks are more readable. I 
originally formatted my func-literals on a single line, because I had come 
from a Ruby background. Over the years I've changed my preference and 
actual prefer the multi-line approach for my functions.

My editor also has a nice little completion where I can type `iferr`, 
followed by a hotkey, and I get the block formatted out for me. This makes 
it even less of an issue for me personally.

If-anything, my preference would be for `gofmt` to forbid single-line func 
literals and to make them multi-line always.

Cheers!
-Tim

On Sunday, January 7, 2018 at 1:09:41 AM UTC+9, Tong Sun wrote:
>
> Hi, 
>
> *[This is just a thought, no flaming please if you don't agree]*
>
> Since `gofmt` supports one line func() definition, how about maintaining 
> one line if statement as well if the user did so? 
>
> This way, many of the simple three line code can be simplified to one:
>
> I.e., from 
>
>  if !condition {
>    return
>  }
>
>
> to just 
>
>  if !condition { return }
>
>
> *provided* that the user uses the one line if format in the first place. 
>
> Thus, a *typical sample* code can be dramatically simplified, because so 
> many three-line error checkings can now be, 
>
> if err != nil { panic("something wrong") }
>
> Thoughts? 
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to