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