> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Go Subtraction Assignment

The `-=` (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.

```go theme={"dark"}
x -= y
```

Semantically, this operation is equivalent to the expanded assignment form, with the exception that the left operand is evaluated exactly once:

```go theme={"dark"}
x = x - y
```

## 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.

**Evaluation Semantics**
Because the left operand is evaluated only once, using `-=` is safer and more efficient when the left operand contains a function call or a complex pointer dereference.

```go theme={"dark"}
// fn() is executed exactly once
matrix[fn()] -= 5 

// fn() is executed twice
matrix[fn()] = matrix[fn()] - 5 
```

**Arithmetic Underflow**
For fixed-size integer types (e.g., `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.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Go Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
