Hacker News new | ask | show | jobs
by kunil 4666 days ago

    // If statements require brace brackets, and do not require parens.
Even if it is single line?
3 comments

Yes, but you shouldn't ever see single-line ifs in go, because gofmt forces all of them to be multi-line.

This is one of the strong points of go (whether you like it or hate it): gofmt imposes the same formatting rules for everyone using the language. It's not a choice for you (or your project) to make. Period.

It's easy enough to never run gofmt, so there is still a choice. :) In fact, not running gofmt requires less effort than running it.
Not if you install the (excellent) GoSublime plugin in Sublime, it will run gofmt on every save.
Learning to use some newfangled editor and figuring out how to install plugins for it when the editor you've always used works just fine sounds like much more work than running gofmt. :)
Yes. After all that's the best style in C and other brace languages too.

This way you can't go wrong adding another statement inside the if.

Yes