> ## 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 Type Alias

A type alias provides an alternative name for an existing type without creating a distinct, new type. To the Go compiler, the alias and the original type are completely identical and interchangeable.

## Syntax

A type alias is declared using the `type` keyword followed by the alias name, an equals sign (`=`), and the existing type.

```go theme={"dark"}
type AliasName = ExistingType
```

The inclusion of the `=` operator is the strict syntactic differentiator between a type alias and a standard type definition.

## Primary Purpose

Introduced in Go 1.9, type aliases were designed specifically for large-scale refactoring and gradual code repair. They allow developers to move a type from one package to another without breaking backward compatibility for existing clients. Type aliases are generally not intended for domain modeling; standard type definitions are heavily preferred in those scenarios to enforce strict type safety.

## Mechanics and Behavior

* **Type Identity:** Because an alias does not create a new type, variables of the alias type and the original type can be assigned to each other directly without explicit type conversion.
* **Method Sets:** An alias shares the exact same method set as the original type. If you define a method on the original type, it is available on the alias. Conversely, you cannot define new methods on an alias of a built-in type or a type defined in another package.
* **Reflection and Type Assertion:** During runtime, the `reflect` package and type assertions will identify the alias strictly as its original type. The alias name is a compile-time construct and is not preserved in the type metadata of the compiled binary.

## Type Alias vs. Type Definition

It is critical to distinguish an alias from a standard type definition. Go does not have "casting"; it relies on explicit type conversions for distinct types.

```go theme={"dark"}
// Type Definition: Creates a distinct, new type.
// Requires explicit type conversion to assign to/from the underlying type.
type DefinedInt int

// Type Alias: Creates an alternate name for the exact same type.
// Requires NO type conversion to assign to/from the underlying type.
type AliasedInt = int
```

## Code Example

The following example demonstrates the strict type equivalence between an alias and its original type:

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

import (
	"fmt"
	"reflect"
)

type Original struct {
	Value int
}

// Declare a type alias
type Alias = Original

func main() {
	var orig Original = Original{Value: 42}
	
	// Implicit assignment is valid because Alias and Original are the same type
	var aliased Alias = orig 

	// Reflection proves the alias resolves to the original type
	fmt.Println(reflect.TypeOf(aliased)) // Output: main.Original
}
```

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