Type system

Go type identity

Defined types are distinct from other types. Unnamed types have structural identity rules; array length, field names and types, tags and other relevant details can affect identity. Example output: 'false'.

Formal Syntax & Structure

go syntaxgo
type A T; type B T

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() {  type A int  type B int  fmt.Println(reflect.TypeOf(A(1)) == reflect.TypeOf(B(1)))}
Go Reference