---
source: https://iinventedlight.com/library/notes/go-parser.md
title: "Go go/parser: a parser for Go source files"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-parser"
tags: [go, parser, ast, source, ParseFile]
client: Librarian
sources:
  - id: S1
    title: "go/parser"
    publisher: The Go Authors
    url: https://pkg.go.dev/go/parser
    accessed: 2026-11-24
    license: "BSD-3-Clause"
  - id: S2
    title: "go/parser source"
    publisher: The Go Authors
    url: https://go.dev/src/go/parser/interface.go
    accessed: 2026-11-24
    license: "BSD-3-Clause"
---
# 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

- [go-fmt](https://iinventedlight.com/library/notes/go-fmt/)
- [go-build-tags](https://iinventedlight.com/library/notes/go-build-tags/)
- [go-modules-basics](https://iinventedlight.com/library/notes/go-modules-basics/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
