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

`int8` is a built-in primitive data type in Go that represents a signed 8-bit integer. It allocates exactly one byte of memory and uses two's complement binary representation to store both positive and negative whole numbers.

**Technical Specifications**

* **Size:** 8 bits (1 byte)
* **Range:** -128 to 127 ($-2^7$ to $2^7 - 1$)
* **Zero Value:** `0`
* **Sign Bit:** The Most Significant Bit (MSB) determines the sign (0 for positive, 1 for negative).
* **Package Constants:** `math.MinInt8` (-128) and `math.MaxInt8` (127)

## Declaration and Initialization

You can declare an `int8` using standard variable declaration syntax. If the type is not explicitly declared, Go will default to `int` for whole numbers, so the `int8` type must be explicitly stated.

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

import "fmt"

func main() {
    // Explicit declaration with initialization
    var a int8 = 127
    
    // Declaration with zero value assignment
    var b int8
    
    // Short variable declaration with explicit type conversion
    c := int8(-128)
    
    fmt.Printf("%T: %d\n", a, a) // Output: int8: 127
    fmt.Printf("%T: %d\n", b, b) // Output: int8: 0
    fmt.Printf("%T: %d\n", c, c) // Output: int8: -128
}
```

## Strict Typing and Conversion

Go enforces strict type safety and does not perform implicit type coercion. An `int8` cannot be directly operated on or compared with other integer types (like `int`, `int16`, or `uint8`) without explicit type conversion.

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

import "fmt"

func main() {
    var x int8 = 50
    var y int = 100

    // invalid operation: x + y (mismatched types int8 and int)
    // result := x + y 

    // Valid: Explicitly convert int8 to int
    result1 := int(x) + y 

    // Valid: Explicitly convert int to int8
    // Note: This will truncate if 'y' exceeds the int8 range
    result2 := x + int8(y) 
    
    fmt.Println(result1, result2) // Output: 150 150
}
```

## Overflow and Underflow Behavior

Because `int8` is constrained to 8 bits, exceeding its maximum or minimum boundaries results in arithmetic wraparound (overflow/underflow) based on two's complement mechanics. Go does not panic on integer overflow during runtime.

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

import "fmt"

func main() {
    var max int8 = 127
    
    // Overflow: 01111111 (127) + 1 = 10000000 (-128)
    max++ 
    fmt.Println(max) // Output: -128

    var min int8 = -128
    
    // Underflow: 10000000 (-128) - 1 = 01111111 (127)
    min--
    fmt.Println(min) // Output: 127
}
```

*Note: While runtime overflow wraps silently, compile-time overflow (e.g., `var x int8 = 128`) will trigger a compiler error: `constant 128 overflows int8`.*

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