From c3d368ec60e645b692a4d71104f21fbd53b7f45b Mon Sep 17 00:00:00 2001 From: kristenwomack Date: Wed, 25 Mar 2026 10:02:55 -0700 Subject: [PATCH] Add Copilot PR review instructions for modern Go 1.26 patterns The Copilot PR reviewer flagged 5 false positives on PR #7223 because it didn't know about Go 1.26 features (e.g. new(expr) for pointer literals) and incorrectly flagged missing imports that existed outside the diff context. These patterns are documented in cli/azd/AGENTS.md but the PR reviewer reads .github/instructions/*.instructions.md files, not AGENTS.md. This adds a focused Go-specific instruction file that covers: - new(expr) pointer literal syntax (Go 1.26) - Other modern Go patterns that should not be flagged - Guidance to check full file context, not just diff hunks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/instructions/go.instructions.md | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/instructions/go.instructions.md diff --git a/.github/instructions/go.instructions.md b/.github/instructions/go.instructions.md new file mode 100644 index 00000000000..776ed82003a --- /dev/null +++ b/.github/instructions/go.instructions.md @@ -0,0 +1,28 @@ +applyTo: + - "**/*.go" +--- +# Modern Go (1.26+) — PR Review Guidelines + +This project uses **Go 1.26** (`cli/azd/go.mod`). Do not flag modern Go 1.26 +features as errors. + +## `new(expr)` creates typed pointers from values + +`new(false)`, `new(true)`, `new(0)`, `new("s")` are **valid Go 1.26**. They +create a pointer to the given value. This replaces helper functions like +`to.Ptr(val)`. Do NOT suggest `boolPtr()` or `&localVar` replacements. + +## Other modern patterns to accept (not flag) + +- `errors.AsType[*T](err)` — generic error unwrapping (replaces `var e *T; errors.As(err, &e)`) +- `for i := range n` — range over integers +- `t.Context()` — test context (replaces `context.Background()` in tests) +- `t.Chdir(dir)` — test directory change (replaces `os.Chdir` + deferred restore) +- `wg.Go(func() { ... })` — WaitGroup shorthand (replaces `wg.Add(1); go func() { defer wg.Done(); ... }()`) +- `min()`, `max()`, `clear()` — built-in functions + +## Review the full file, not just the diff + +Before flagging missing imports or undefined references, verify the symbol isn't +already defined in unchanged portions of the file. The diff context may not show +all existing imports or declarations.