← All notes

Go ast: types for Go syntax trees

Answer: The ast package declares the types used to represent syntax trees for Go packages.

How trees are built

They are typically produced from Go source code by the parser.

All node types implement the Node interface.

Filtering and printing

A filter can drop import declarations from a file.

If the declaration is empty afterwards, the declaration is removed from the AST.

Unexported struct fields are never printed.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, go/ast; The Go Authors, go/ast source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, go/ast; The Go Authors, go/ast source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.

Cite this

Permanent ID: iil:note:tzr6m1tb

iinventedlight. 2026. "Go ast: types for Go syntax trees." iinventedlight Library, iil:note:tzr6m1tb, version of 2026-11-25. https://iinventedlight.com/library/notes/go-ast/. License: CC-BY-4.0.

@misc{iil_note_tzr6m1tb,
  author = {{iinventedlight}},
  title = {{Go ast: types for Go syntax trees}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-25},
  url = {https://iinventedlight.com/library/notes/go-ast/},
  note = {Permanent ID iil:note:tzr6m1tb. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-ast.md.