Standard library / go/types
go/types.Implements()
Reports whether a type implements an interface. Use Satisfies for constraint satisfaction. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func Implements(V Type, T *Interface) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| V | Type | Source or candidate type. |
| T | *Interface | Destination type or interface, or type to inspect. |
Return Value
bool
Reports whether a type implements an interface.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { fmt.Println(types.Implements(types.Typ[types.Int], types.NewInterfaceType(nil, nil).Complete()))}