On Fri, Jul 5, 2019 at 11:55 AM Malcolm Gorman wrote:
> If these single-statement if statements could be:
>
> if err != nil { return , err }
>
> the visual appearance of code would become far more compact and easier to
> read, and we wouldn't need any special new syntax.
I prefer the opposite.
Excellent idea!
Occasionally an error message needs to be created or elaborated, requiring
a multi-line if statement body.
But the common situation is where the error is simply returned to the
calling function using a single-statement if statement.
If these single-statement if statements could
At the moment func declarations leave it for the user, depending on whether
the original was written on one line or not.
gofmt will change:
func hi(){fmt.Println("Hi.")}
func bye(){
fmt.Println("Bye.")}
into:
func hi() { fmt.Println("Hi.") }
func bye() {
fmt.Pri
Yes, but ...
First the "yes" part.
I find myself writing one line if statements, and then finding myself
annoyed at gofmt. When I write a one line if statement, there is a
presentational reason for it.
But
But such formatting would have to be an all or nothing thing if we wanted
consistency
I like the C if one-liner without curly braces but that doesn't apply to Go
since the if condition isn't in parenthesis.
if (exists == false) i++;
I've never liked the non-braces version of if when across multiple lines.
In JavaScript I've started always writing out if like in Go and will
prob
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 commi