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) bool

Parameters & Attributes

NameTypeDescription
tTypeType 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]))}
Go Reference