Standard library / go/types
go/types.IsInterface()
Reports whether the underlying type is an interface. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func IsInterface(t Type) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| t | Type | Type to inspect or normalize. |
Return Value
bool
Reports whether the underlying type is an interface.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { fmt.Println(types.IsInterface(types.NewInterfaceType(nil, nil).Complete()), types.IsInterface(types.Typ[types.Int]))}