Standard library / go/types

go/types.Scope.NumChildren()

Returns the number of direct child scopes. Expected stdout: '1\n'.

Formal Syntax & Structure

go syntaxgo
func (s *Scope) NumChildren() int

Return Value

int

Returns the number of direct child scopes.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func scope() *types.Scope {  s := types.NewScope(nil, 10, 100, "outer")  types.NewScope(s, 20, 40, "inner")  s.Insert(types.NewVar(11, nil, "X", types.Typ[types.Int]))  return s}
func main() { v := scope(); fmt.Println(v.NumChildren()) }
Go Reference