Standard library / go/ast

go/ast.Decl

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

Formal Syntax & Structure

go syntaxgo
type Decl interface {  Node}

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/ast"  "go/token")
func main() { var n ast.Decl = &ast.GenDecl{Tok: token.VAR}; fmt.Printf("%T\n", n) }
Go Reference