Standard library / reflect

reflect.Method.IsExported()

Report whether the method is exported. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (m Method) IsExported() bool

Return Value

bool

Report whether the method is exported.

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
type Item struct{}
func (Item) Name() string { return "demo" }func main()               { m, _ := reflect.TypeOf(Item{}).MethodByName("Name"); fmt.Println(m.IsExported()) }
Go Reference