Standard library / reflect
reflect.Value.NumMethod()
Return the number of accessible methods; for concrete types only exported methods are counted. Expected stdout: '1\n'.
Formal Syntax & Structure
go syntaxgo
func (v Value) NumMethod() intReturn Value
int
Return the number of accessible methods; for concrete types only exported methods are counted.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
type Item struct{}
func (Item) Name() string { return "demo" }func main() { fmt.Println(reflect.ValueOf(Item{}).NumMethod()) }