Type system

Go defined types

A type definition introduces a distinct type with the given underlying type. Identical underlying types alone do not make two defined types interchangeable. Example output: 'main.Meter 3'.

Formal Syntax & Structure

go syntaxgo
type Name T

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  type Meter int  var m Meter = 3  fmt.Printf("%T %d\n", m, int(m))}
Go Reference