In Go, type and interface are related but serve different purposes. Let’s break it down:


1️⃣ type

Examples:

New basic type:

type MyInt int

Struct type:

type Person struct {
    Name string
    Age  int
}

Function type:

type Adder func(a, b int) int

Interface type:

type Speaker interface {
    Speak() string
}

Notice that interface itself is defined via type.


2️⃣ interface