> ## 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 Bitwise OR Assignment

The `|=` operator is the bitwise OR assignment operator in Go. It performs a bitwise OR operation between the left and right integer operands and assigns the resulting value directly to the left operand.

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

This is a syntactic shorthand equivalent to:

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

## Mechanics

The operator evaluates the binary representation of both operands. For each corresponding bit position, it applies the logical OR operation: if at least one of the compared bits is `1`, the resulting bit is set to `1`. If both bits are `0`, the resulting bit remains `0`.

**Bitwise OR Truth Table:**
\| Bit `x` | Bit `y` | Result (`x | y`) |
\| :---: | :---: | :---: |
\| 0 | 0 | **0** |
\| 0 | 1 | **1** |
\| 1 | 0 | **1** |
\| 1 | 1 | **1** |

## Code Visualization

```go theme={"dark"}
package main

import "fmt"

func main() {
    var a uint8 = 10 // Binary: 00001010
    var b uint8 = 6  // Binary: 00000110

    a |= b           // Evaluates: 00001010 | 00000110

    fmt.Printf("%08b\n", a) // Output: 00001110 (Decimal: 14)
}
```

## Type Constraints

1. **Integer Types Only:** The `|=` operator can only be applied to integer types (e.g., `int`, `int32`, `uint8`, `byte`, `rune`). Attempting to use it with floating-point numbers (`float32`, `float64`), complex numbers, or non-numeric types will result in a compile-time error.
2. **Type Matching:** The right-hand operand must be assignable to the type of the left-hand operand. If they are of different explicitly declared integer types, you must perform a type conversion before applying the operator.

```go theme={"dark"}
var x int32 = 4
var y int64 = 8

// x |= y // Compile error: invalid operation: mismatched types int32 and int64
x |= int32(y) // Valid
```

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