I thought I'd expound a bit on one of my recent tweets that garnered more attention than usual:
Pointless Style Differentiation
"But Brian," you say, "it's not that big of a deal." And you are right. But many man hours will still be wasted over something that is not a big deal.
Two Rules Are Worse Than One
Here's the relevant part of the Go Language Spec:
The formal grammar uses semicolons ";" as terminators in a number of productions. Go programs may omit most of these semicolons using the following two rules:
- When the input is broken into tokens, a semicolon is automatically inserted into the token stream at the end of a non-blank line if the line's final token is
- an identifier
- an integer, floating-point, imaginary, rune, or string literal
- one of the keywords break, continue, fallthrough, or return
- one of the operators and delimiters ++, --, ), ], or }
- To allow complex statements to occupy a single line, a semicolon may be omitted before a closing ")" or "}".
Rather than remembering these "two" rules, you can remember this one rule: put a semicolon at the end of your statement. I don't think saving a keystroke here and there is worth having to think so hard about something so simple.
I am still very much interested in Go. Consider this bit about semicolons a strong opinion, weakly held; I'd love to hear some counter arguments, so feel free to tweet me.