Operator and syntax

Go operator precedence

Unary operators bind more tightly than binary operators. Binary operators at the same precedence associate left to right. Parentheses override grouping; precedence is not a complete rule for evaluation order. Example output: '14 20 2'.

Formal Syntax & Structure

go syntaxgo
unary; * / % << >> & &^; + - | ^; == != < <= > >=; &&; ||

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  fmt.Println(2+3*4, (2+3)*4, 20/5/2)}
Go Reference