Standard library / go/types

go/types.Scope.Parent()

Returns the enclosing scope or nil. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (s *Scope) Parent() *Scope

Return Value

*Scope

Returns the enclosing scope or nil.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func main() {  p := types.NewScope(nil, 1, 20, "p")  s := types.NewScope(p, 5, 10, "child")  fmt.Println(s.Parent() == p)}
Go Reference