Re:gofumpt: It's like gofmt except more strict
by bxparks on Saturday February 11, 2023 @11:26AM
(#34753698)
As far as I understand, that's a consequence of the automatic insertion of trailing semicolon by the lexer, not a decision by gofmt. It's explained here:
https://go.dev/doc/effective_go#semicolons
[ Parent
| on HN ]
Re:gofumpt: It's like gofmt except more strict
by layer8 on Saturday February 11, 2023 @11:57AM
(#34754017)
I see. That doesn’t seem very sensible in potential-beginning-of-block contexts, in particular in the if case where an implicit empty statement is deduced after the condition.
Re:gofumpt: It's like gofmt except more strict
by nordsieck on Saturday February 11, 2023 @06:13PM
(#34757428)
> That doesn’t seem very sensible in potential-beginning-of-block contexts, in particular in the if case where an implicit empty statement is deduced after the condition.
Are you referring to C style if statements where you can elide the braces?
In go the braces are mandatory, so I don't think that really applies.
Re:gofumpt: It's like gofmt except more strict
by layer8 on Saturday February 11, 2023 @07:40PM
(#34758115)
I was referring to the Go documentation linked above:
> One consequence of the semicolon insertion rules is that you cannot put the opening brace of a control structure (if, for, switch, or select) on the next line. If you do, a semicolon will be inserted before the brace, which could cause unwanted effects.
I was assuming that the “unwanted effects” are not just a syntax error.