Standard library / go/types
go/types.Scope.Innermost()
Returns the deepest child scope containing a position, or nil if outside. Expected stdout: 'true true\n'.
Formal Syntax & Structure
go syntaxgo
func (s *Scope) Innermost(pos token.Pos) *ScopeParameters & Attributes
| Name | Type | Description |
|---|---|---|
| pos | token.Pos | Source position in the associated file set. |
Return Value
*Scope
Returns the deepest child scope containing a position, or nil if outside.
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.Innermost(25) == v.Child(0), v.Innermost(100) == nil) }