TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
-= (subtraction assignment) operator is a compound assignment operator that subtracts the value of the right operand from the left operand and assigns the resulting difference back to the left operand.
Technical Mechanics and Constraints
Assignable Expressions The left operand must be an addressable expression or a map index expression. Valid left-hand side operands include variables, pointer indirections, array elements, slice elements, and map elements. It cannot be a literal, a constant, or the result of a function call returning a value. While map index expressions (e.g.,m[key]) are explicitly not addressable in Go, the language specification carves them out as a valid exception for assignment operations.
Type Compatibility
Go enforces strict type safety for compound assignments.
- Both operands must resolve to identical numeric types (e.g.,
int,float64,complex128). - If the right operand is an untyped constant, it must be implicitly convertible to the declared type of the left operand without truncation or overflow.
- The operator does not support strings, booleans, or custom structs.
-= is safer and more efficient when the left operand contains a function call or a complex pointer dereference.
uint8, int32), the -= operator is subject to standard two’s complement arithmetic wrap-around. If the subtraction results in a value below the minimum representable bound of the left operand’s type, it will silently underflow. The Go compiler and runtime do not trigger a panic on integer underflow.
Master Go with Deep Grasping Methodology!Learn More





