5 ms·
// If statements require brace brackets, and do not require parens. Even if it is single line?
by kunil 13y ago
// If statements require brace brackets, and do not require parens.
Even if it is single line?
- nanofortnight 13y agoYes
- kilburn 13y agoYes, 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.
- omaranto 13y agoIt's easy enough to never run gofmt, so there is still a choice. :) In fact, not running gofmt requires less effort than running it.
- melvinmt 13y agoNot if you install the (excellent) GoSublime plugin in Sublime, it will run gofmt on every save.
- omaranto 13y agoLearning 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. :)
- coldtea 13y agoYes. 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.
- drivebyacct2 13y agoAlways use braces. So many stupid bugs. Just use them. It's easier for everyone else. Including yourself later when you go back and add to it.