Literal

Automatic semicolon insertion

Go inserts semicolons after certain final tokens on a line, including identifiers, literals, return and closing delimiters. Moving the opening brace of an if header onto the next line can make it invalid. Example output: 'ok'.

Formal Syntax & Structure

go syntaxgo
if condition { statement}

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  if true {    fmt.Println("ok")  }}
Go Reference