Standard library / go/types

go/types.NewScope()

Creates a lexical scope associated with an enclosing scope and source interval. Expected stdout: 'true false\n'.

Formal Syntax & Structure

go syntaxgo
func NewScope(parent *Scope, pos, end token.Pos, comment string) *Scope

Parameters & Attributes

NameTypeDescription
parent*ScopeEnclosing scope, or nil for an outermost scope.
postoken.PosSource position in the associated file set.
endtoken.PosExclusive ending source position.
commentstringInput to the operation as described above.

Return Value

*Scope

Creates a lexical scope associated with an enclosing scope and source interval.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func main() { s := types.NewScope(nil, 1, 10, "demo"); fmt.Println(s.Contains(1), s.Contains(10)) }
Go Reference