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) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | Type | First type or expression to inspect. |
| y | Type | Second 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])))}