Standard library / go/ast

go/ast.Node

Interface for node syntax nodes. Node positions are exposed through Pos and End; concrete forms can be distinguished with a type switch. Expected stdout: '*ast.Ident\n'.

Formal Syntax & Structure

go syntaxgo
type Node interface {  Pos() token.Pos  End() token.Pos}

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/ast")
func main() { var n ast.Node = ast.NewIdent("x"); fmt.Printf("%T\n", n) }
Go Reference