Go go/parser: a parser for Go source files
Answer: Package parser implements a parser for Go source files.
Entry points
ParseFile reads file input from a string, a byte slice, or a reader, and produces an abstract syntax tree of the file.
Position information is recorded in fset, which must not be nil.
The mode bits are passed to ParseFile unchanged.
ParseDir does not consider build tags when associating files with packages.
What the source comments say
This file contains the exported entry points for invoking the parser.
A Mode value is a set of flags, or zero.
Those flags control the amount of source code parsed and other optional parser functionality.
ParseFile parses the source code of a single Go source file and returns the corresponding file node.
See also
Claims
- id: C1 claim: Package parser implements a parser for Go source files. source: S1 evidence: "Package parser implements a parser for Go source files."
- id: C2 claim: Position information is recorded in fset, which must not be nil. source: S1 evidence: "Position information is recorded in fset, which must not be nil."
- id: C3 claim: The mode bits are passed to ParseFile unchanged. source: S1 evidence: "The mode bits are passed to ParseFile unchanged."
- id: C4 claim: This file contains the exported entry points for invoking the parser. source: S2 evidence: "This file contains the exported entry points for invoking the parser."
Sources
- [S1] go/parser. The Go Authors. https://pkg.go.dev/go/parser . License: BSD-3-Clause. Accessed 2026-11-24.
- [S2] go/parser source. The Go Authors. https://go.dev/src/go/parser/interface.go . License: BSD-3-Clause. Accessed 2026-11-24.
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/parser; The Go Authors, go/parser 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/parser; The Go Authors, go/parser source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go go/parser: a parser for Go source files." iinventedlight Library, iil:note:efnhjpe2, version of 2026-11-24. https://iinventedlight.com/library/notes/go-parser/. License: CC-BY-4.0.
@misc{iil_note_efnhjpe2,
author = {{iinventedlight}},
title = {{Go go/parser: a parser for Go source files}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/go-parser/},
note = {Permanent ID iil:note:efnhjpe2. License: CC-BY-4.0.},
}
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.
- go-parser.schema.json (schema; CC-BY-4.0)
- go-parser.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-parser.md.