[go] go/ast: add ParseDirective for parsing directive comments

1 view
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Oct 21, 2025, 5:49:15 PM (2 days ago) Oct 21
to Austin Clements, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Alan Donovan, Mateusz Poliwczak, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

7 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: src/go/ast/directive.go
Insertions: 1, Deletions: 1.

@@ -112,7 +112,7 @@
// double quoted Go string, or a back quoted raw Go string. Each token must be
// separated by one or more Unicode spaces.
//
-// If the arguments do not obey this syntax, it returns an error.
+// If the arguments do not conform to this syntax, it returns an error.
func (d *Directive) ParseArgs() ([]DirectiveArg, error) {
args := directiveScanner{d.Args, d.ArgsPos}

```

Change information

Commit message:
go/ast: add ParseDirective for parsing directive comments

This adds an ast.Directive API for parsing directive comments such as
"//go:build" and "//go:embed".

This will help tools standardize the syntax of these directive
comments. Even within the standard Go tools there's little agreement
on the finer details of the syntax of directives today.

Fixes #68021.
Change-Id: I84a988a667682c9ac70632df6e925461ac95e381
Auto-Submit: Austin Clements <aus...@google.com>
Reviewed-by: Mateusz Poliwczak <mpoliw...@gmail.com>
Reviewed-by: Alan Donovan <adon...@google.com>
Files:
  • A api/next/68021.txt
  • A doc/next/6-stdlib/99-minor/go/ast/68021.md
  • A src/go/ast/directive.go
  • A src/go/ast/directive_test.go
Change size: L
Delta: 4 files changed, 447 insertions(+), 0 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Mateusz Poliwczak, +2 by Alan Donovan
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I84a988a667682c9ac70632df6e925461ac95e381
Gerrit-Change-Number: 704835
Gerrit-PatchSet: 10
Gerrit-Owner: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Austin Clements <aus...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Mateusz Poliwczak <mpoliw...@gmail.com>
Gerrit-CC: jimmy frasche <soapbo...@gmail.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages