Operator and syntax

Go delimiters and separators

Parentheses group expressions and delimit calls; brackets delimit indexing, arrays and type parameters; braces delimit blocks and composite literals. Commas separate list elements and colons appear in labels, cases and keyed literals. Semicolons separate statements and are often inserted automatically. Example output: '1'.

Formal Syntax & Structure

go syntaxgo
( ) [ ] { } , ; :

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  a := []int{1, 2}  if len(a) > 0 {    fmt.Println(a[0])  }}
Go Reference