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

`uint8` is a built-in primitive data type in Go representing an unsigned 8-bit integer. It allocates exactly one byte of memory and strictly stores non-negative whole numbers.

## Technical Specifications

* **Memory Size:** 8 bits (1 byte)
* **Minimum Value:** `0`
* **Maximum Value:** `255` ($2^8 - 1$)
* **Zero Value:** `0`
* **Alias:** `byte`

## Syntax and Initialization

You can declare and initialize a `uint8` using standard Go variable declaration patterns. If uninitialized, it defaults to its zero value.

```go theme={"dark"}
// Explicit declaration with initialization
var maxVal uint8 = 255

// Declaration relying on zero value (defaults to 0)
var defaultVal uint8

// Short variable declaration with type conversion
inferredVal := uint8(128)
```

## The `byte` Alias

In Go, `byte` is a predeclared identifier that serves as a direct alias for `uint8`. They are entirely interchangeable and identical to the compiler. No explicit type conversion is required when assigning a `uint8` to a `byte` or vice versa.

```go theme={"dark"}
var u uint8 = 65
var b byte = u // Valid: byte and uint8 are the exact same type

fmt.Printf("%T", b) // Output: uint8
```

## Overflow and Underflow Mechanics

Because `uint8` is strictly bounded between 0 and 255, exceeding these limits results in different behaviors depending on whether the evaluation occurs at compile-time or run-time.

**Compile-time:** Assigning an out-of-bounds constant yields a compilation error.

```go theme={"dark"}
// compiler error: constant 256 overflows uint8
var invalid uint8 = 256 

// compiler error: constant -1 overflows uint8
var negative uint8 = -1 
```

**Run-time:** Standard arithmetic operations that exceed the bounds will silently wrap around (modulo $2^8$).

```go theme={"dark"}
var val uint8 = 255
val++ 
// val is now 0 (Overflow wraparound)

var zero uint8 = 0
zero-- 
// zero is now 255 (Underflow wraparound)
```

## Type Conversion

Go requires explicit type conversion when performing arithmetic or assignments between `uint8` and other integer types (like `int`, `uint16`, or `int8`), even if the value fits within the target type's bounds.

```go theme={"dark"}
var a uint8 = 100
var b int = 200

// Invalid: mismatched types uint8 and int
// result := a + b 

// Valid: explicit conversion
result := int(a) + b
```

## Formatting Verbs

When using the `fmt` package, `uint8` values can be formatted into various string representations using standard integer verbs:

```go theme={"dark"}
var num uint8 = 255

fmt.Printf("%d", num) // Base 10: 255
fmt.Printf("%b", num) // Base 2:  11111111
fmt.Printf("%x", num) // Base 16: ff
fmt.Printf("%c", num) // Unicode: ÿ (character representation of decimal 255)
```

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