correct:
if(true) {
}
incorrect:
if(true)
{
}
Why is this style enforced, does it have something to do with the language spec, or is it just because they prefer one style over another ?
Why are there braces but no semicolons? And why can't I put the opening brace on the next line?
Go uses brace brackets for statement grouping, a syntax familiar to programmers who have worked with any language in the C family. Semicolons, however, are for parsers, not for people, and we wanted to eliminate them as much as possible. To achieve this goal, Go borrows a trick from BCPL: the semicolons that separate statements are in the formal grammar but are injected automatically, without lookahead, by the lexer at the end of any line that could be the end of a statement. This works very well in practice but has the effect that it forces a brace style. For instance, the opening brace of a function cannot appear on a line by itself.