1 go rules available
GitHub Copilot picks up .github/instructions/*.instructions.md files whose applyTo glob matches the file you are working on, in VS Code and Visual Studio. The one Copilot Go rule is a substantive Go development rule; the file below adapts it for inline suggestions and Copilot code review on .go files.
GitHub Copilot reads repository-wide custom instructions from .github/copilot-instructions.md and path-specific instructions from .github/instructions/*.instructions.md files with an applyTo glob. Copilot can also use AGENTS.md files, where the nearest file in the directory tree takes precedence. Which file types are honored depends on the surface: VS Code, Visual Studio, JetBrains, Xcode, Eclipse and GitHub.com differ.
.github/instructions/go.instructions.mdStarting point, not a tested configuration for your repository. Used for files matching applyTo on surfaces that support path-specific instructions. Review the instructions, adapt the file paths and run your project's existing checks.
---
applyTo: "**/*.go"
---
# Go instructions for GitHub Copilot
## Focus for this project
- When reviewing, flag returned errors that drop context (return err with no wrapping at package boundaries).
- Flag I/O functions that do not accept a context.Context.
- Suggest table-driven tests with t.Run for new exported functions.
## Go conventions
- Read the go directive in go.mod before using newer standard-library APIs. With go 1.22 or later, register routes with method and wildcard patterns such as mux.HandleFunc("GET /users/{id}", h) and read the value with r.PathValue("id"); on older modules keep the router the project already uses.
- Pass context.Context as the first parameter of any function that does I/O, and stop work when ctx.Done() closes.
- Wrap errors with fmt.Errorf("...: %w", err) and compare with errors.Is or errors.As; never compare error strings.
- Write table-driven tests with t.Run subtests next to the code (foo_test.go).
## Before you finish
- Run gofmt -l . (must print nothing), go vet ./... and go test -race ./... and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass.
- Summarize which of the rules above affected the change.
- When reviewing a pull request, comment only where a change breaks one of these instructions and quote the instruction.
Create your own GitHub Copilot rules for Go and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Instruction support differs by surface: VS Code supports repository-wide, path-specific and AGENTS.md instructions; Visual Studio supports repository-wide and path-specific; JetBrains and Xcode use .github/copilot-instructions.md. GitHub's documentation describes AGENTS.md files stored anywhere in the repository, with the nearest file in the directory tree taking precedence, or alternatively a single CLAUDE.md or GEMINI.md in the root. Support differs by surface; GitHub's IDE page lists AGENTS.md among the instruction types for VS Code.
Documentation checked 2026-11-05: GitHub Docs: Adding repository custom instructionsGitHub Docs: Repository instructions in your IDE
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Your team uses Copilot completions and Copilot code review on a Go service and wants reviews to flag unwrapped errors and missing context propagation.
Review this diff that adds a function calling the payments API with http.Get.
Review comments asking for http.NewRequestWithContext with a ctx parameter, error wrapping with %w, and a table-driven test; no comments about unrelated style.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.