Standard library / go/types

go/types.Default()

Returns the default type for an untyped type, or the original type otherwise. Untyped nil has no default concrete type. Expected stdout: 'int\n'.

Formal Syntax & Structure

go syntaxgo
func Default(t Type) Type

Parameters & Attributes

NameTypeDescription
tTypeType to inspect or normalize.

Return Value

Type

Returns the default type for an untyped type, or the original type otherwise.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func main() { fmt.Println(types.Default(types.Typ[types.UntypedInt])) }
Go Reference