Dangling else in Go
By design, Go doesn't have dangling else problem as it requires block (wrapped in curly brackets) as stated in the Go programming language specification [1]:
Each "if", "for", and "switch" statement is considered to be in its own implicit block.
The BNF [2] for if
statement is shown below:
IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block ) ] .