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) *ScopeParameters & Attributes
| Name | Type | Description |
|---|---|---|
| parent | *Scope | Enclosing scope, or nil for an outermost scope. |
| pos | token.Pos | Source position in the associated file set. |
| end | token.Pos | Exclusive ending source position. |
| comment | string | Input 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)) }