Standard library / go/types

go/types.Scope.String()

Formats the scope for debugging; text may include process-specific addresses. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (s *Scope) String() string

Return Value

string

Formats the scope for debugging; text may include process-specific addresses.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types"  "strings")
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(strings.Contains(v.String(), "X")) }
Go Reference