Standard library / go/types

go/types.Identical()

Reports whether two types are identical under Go type identity rules. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func Identical(x, y Type) bool

Parameters & Attributes

NameTypeDescription
xTypeFirst type or expression to inspect.
yTypeSecond type for comparison.

Return Value

bool

Reports whether two types are identical under Go type identity rules.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func main() {  fmt.Println(types.Identical(types.NewSlice(types.Typ[types.Int]), types.NewSlice(types.Typ[types.Int])))}
Go Reference