Go uses semicolons under the hood. But the developer should never add them themselves.
If the last token before a newline is any of the following, the lexer inserts a semicolon after the token:
- An identifier (which includes words like
int
andfloat64
) - A basic literal such as a number or string constant
- One of the tokens:
break
,continue
,fallthrough
,return
,++
,--
,)
, or}
Example
is translated into
that is not a valid Go.