We use cookies.This website uses essential cookies to operate core features. With your consent, we also use analytics cookies to understand traffic and improve the service. For more details, see our .
Go Operator Precedence Checker
Was this tool helpful to use?
Your feedback helps us make it better
Quickly check Go operator precedence and associativity to understand expression evaluation order. Free online Golang operator lookup tool.
A curated syntax reference, not a compiler or example validator. Local group numbers do not replace version-specific grammar, typing or evaluation rules. Examples keep their original code and literals. Groups 8/9 contain statements, not expression precedence. Reference
x.yPrimary ExpressionsLeft-associative访问结构体字段、包成员或方法。主表达式优先级最高。
user.Namex[i]Primary ExpressionsLeft-associative访问数组、切片、字符串或 map 的元素。
items[i]x[i:j]Primary ExpressionsLeft-associative从数组、切片或字符串中取得半开区间。
name[1:4]x.(T)Primary ExpressionsLeft-associative从接口值中取出动态类型为 T 的值。
value.(string)f()Primary ExpressionsLeft-associative调用函数、方法或可调用表达式。
fmt.Println(name)+xUnary OperatorsRight-associative返回数值本身,通常用于强调符号。
+count-xUnary OperatorsRight-associative返回数值的相反数。
-delta!Unary OperatorsRight-associative对布尔值取反。
!ok^xUnary OperatorsRight-associative对整数逐位取反。
^mask*pUnary OperatorsRight-associative读取指针指向的值。
*ptr&xUnary OperatorsRight-associative取得变量、字段或可寻址值的指针。
&value<-chUnary OperatorsRight-associative从 channel 接收一个值,可用于表达式。
value := <-ch*Multiplicative and ShiftLeft-associative两个数值相乘。
width * height/Multiplicative and ShiftLeft-associative左操作数除以右操作数;整数除法会截断小数部分。
total / count%Multiplicative and ShiftLeft-associative返回整数除法的余数。
index % 2<<Multiplicative and ShiftLeft-associative将整数按位左移指定数量。
1 << bit>>Multiplicative and ShiftLeft-associative将整数按位右移指定数量。
flags >> 1&Multiplicative and ShiftLeft-associative两个整数逐位执行与运算。
flags & enabled&^Multiplicative and ShiftLeft-associative清除左操作数中右操作数为 1 的位。
flags &^ disabled+Additive and BitwiseLeft-associative数值相加;字符串相加时执行拼接。
first + last-Additive and BitwiseLeft-associative左操作数减去右操作数。
end - start|Additive and BitwiseLeft-associative两个整数逐位执行或运算。
flags | selected^Additive and BitwiseLeft-associative两个整数逐位执行异或运算。
flags ^ mask==Comparison OperatorsLeft-associative判断两个可比较值是否相等。
status == "ok"!=Comparison OperatorsLeft-associative判断两个可比较值是否不相等。
err != nil<Comparison OperatorsLeft-associative比较左操作数是否小于右操作数。
age < 18<=Comparison OperatorsLeft-associative比较左操作数是否小于或等于右操作数。
score <= 100>Comparison OperatorsLeft-associative比较左操作数是否大于右操作数。
price > limit>=Comparison OperatorsLeft-associative比较左操作数是否大于或等于右操作数。
count >= min&&Logical OperatorsLeft-associative左侧为 false 时短路,不再计算右侧。
ok && ready||Logical OperatorsLeft-associative左侧为 true 时短路,不再计算右侧。
cached || fallback=Assignment OperatorsRight-associative将右侧值赋给左侧变量。Go 的赋值是语句,不作为表达式参与运算。
count = 10:=Assignment OperatorsRight-associative声明并初始化局部变量。它是语句,不是表达式运算符。
name := "toolkk"+= -= *= /=Assignment OperatorsRight-associative把二元运算结果写回左侧变量;还包括 %=、<<=、>>=、&=、&^=、|=、^=。
total += price++ --OtherNoneGo 中自增和自减只能作为语句使用,不能嵌入表达式。
i++<-OtherNone向 channel 发送值时是语句形式,不作为表达式求值。
ch <- valueOverview
Understand what the tool solves, how it works, and the boundaries of its data.
This page is a searchable reference for Go operators and related syntax examples. Enter a symbol or a word from an entry’s name, description, or example; you can also search the displayed rank number. Narrow the list with a category and an associativity filter. Matching entries show the symbol, a short explanation, an example, and controls to copy the symbol or example.
For example, searching &^ finds the bit-clear operator, while searching channel can find channel receive or send entries. The page filters reference cards; it does not accept a complete expression for parsing, execution, type checking, or compilation.
Precedence determines how an expression is grouped when parentheses are absent. The Go specification assigns five numbered levels to binary operators: 5 binds most tightly and 1 least tightly. Operators at the same binary level group from left to right. Unary operators bind more tightly than binary operators.
| Go specification level | Binary operators | Example grouping |
|---|---|---|
| 5, highest | * / % << >> & &^ | a * b |
| 4 | + - | ^ | a + b |
| 3 | == != < <= > >= | a < b |
| 2 | && | a && b |
| 1, lowest | || | a || b |
Thus a + b * c groups as a + (b * c), and a || b && c groups as a || (b && c). This describes syntax grouping, not the order in which every operand’s effects happen. The Go specification’s Operators section is the authority for language rules.
The number shown on a result card is this page’s browsing rank, where a lower number is presented as higher. The catalogue includes primary expressions, unary forms, the five binary groups, assignment statements, increment/decrement statements, and channel-send syntax. That single browsing rank is not the specification’s five-level binary table: for example, the reference lists primary expressions at rank 1, unary forms at rank 2, multiplication at rank 3, and logical OR at rank 7.
Use the category label and the actual symbol to identify what an entry represents. Assignment (=, :=), increment/decrement (++, --), and channel send (<- in statement form) are not additional binary precedence levels. The reference’s descriptions and examples help locate syntax; consult the specification when you need the language rule.
Guide
Follow the workflow and verify inputs and outputs with practical examples.
Search with the full symbol, such as &^, <<, or !=, or try a term such as shift, channel, or an example fragment. A rank number can also narrow matches. Clear the keyword to see all entries within the selected filters.
Filter by primary expressions, unary operators, multiplicative and shift operators, additive and bitwise operators, comparisons, logical operators, assignments, or other syntax. The associativity filter further selects left, right, or no associativity as recorded for those cards.
Check its category, explanation, and sample before copying a symbol or example. Add parentheses when you want grouping to be explicit, and compile your own code to check syntax and types.
Use cases
See how the tool fits into real work and everyday tasks.
When a condition mixes comparison, &&, and ||, look up the operators and rewrite the grouping with parentheses, such as ready || cached && valid becoming ready || (cached && valid). This makes the intended structure easier to discuss.
Search for &^, a shift symbol, or <- to find a named entry and example. Then use the category and specification distinction to tell a binary operator from unary or statement syntax.
Q&A
Find concise answers to common questions and confusing cases.
The card number is a page browsing rank across several categories. The specification’s five numbered levels apply to binary operators, with 5 highest and 1 lowest. Compare the operator group, not the page rank, with that table.
No. It searches reference cards and displays descriptions and examples. It does not parse or run an expression, validate operand types, compile code, or report a runtime value.
++, --, and assignment part of the expression precedence table?No. Go treats ++ and -- as statements, and assignment is also statement syntax. They can appear in this broader catalogue for lookup, but they are not extra entries in the specification’s five binary precedence levels.
Notes
Review scope, result limitations, and important precautions before use.
The catalogue’s rank and associativity labels organize reference entries; they are not a substitute for Go’s syntax specification. In particular, do not infer that assignment chains behave like right-associative expressions in Go: assignment is a statement, not an expression that returns a value. Examples are illustrative snippets and do not establish that a particular expression is valid for your types or program context. When grouping is important, add parentheses and verify the code with the Go toolchain.
Related
Discover related tools, collections, and available API capabilities.