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
If this tool helped you, you can buy us a coffee ☕
Quickly check Go operator precedence and associativity to understand expression evaluation order. Free online Golang operator lookup tool.
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 <- value
JSON to Go Struct Converter
Convert JSON data into Go struct definition code for API integration and data modeling.

JSON Formatter
Process JSON data online: format, minify, and validate to boost your development and debugging efficiency.

PYC Decompiler
Restore Python bytecode .pyc files into readable source code for easy code auditing and learning. Supports mainstream versions.
When writing Go expressions, uncertainty about operator precedence can lead to logical errors. Based on the official Go language specification, this tool allows you to input any operator to quickly check its precedence level and associativity, helping developers clarify the evaluation order of expressions.
+, *, ==, &&, or <-. Pay attention to single-character vs. double-character operators.* outputs a precedence of 5 and left associativity; entering == outputs a precedence of 3 and left associativity; entering ! outputs a precedence of 5 and right associativity (unary operator).a = b = 3 will first assign 3 to b, and then assign the result to a.Please ensure you enter a valid Go language operator; invalid characters will trigger an error. This tool is based on the Go language specification, where operator precedence is fixed and not affected by context. The query only returns precedence and associativity information and does not evaluate expressions, ensuring your code privacy is protected.
Go operator precedence is divided into 5 levels. From highest to lowest: unary operators (^ ! - +) etc. have a precedence of 5; multiplication, division, and modulo are 5; addition, subtraction, and string concatenation are 4; comparison is 3; logical AND && is 2; logical OR || is 1. Assignment operators have the lowest precedence. In actual coding, it is highly recommended to use parentheses to explicitly define precedence and improve code readability.