On Wed, Dec 13, 2017 at 11:01 AM, Pablo Rozas Larraondo
<p.rozas.larrao...@gmail.com> wrote:
> Hello,
>
> I'm curious to know if this is intended:
>
> https://play.golang.org/p/t353t8ZvL1

This is intentional. gofmt uses spacing to group expressions based on
precedence of operators.
eg.

(i+2)/2 + 1 //In this line it's clear that 2 is added to i, that value
is divided by 2 and then added to 1.
(i + 2) / 2 + 1 // The formating here make the order of precedence less clear


> Line 9 is formatted with spaces but line 10 has no spaces. It seems like
> adding +1 to the expression changes the behaviour of "gofmt". Wouldn't it be
> simpler for "gofmt" to always add spaces between the operators? Maybe
> someone knows the reason for this.

-- 
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