go-style-guide

go-style-guide is an agent for coding agents from canonical/copilot-collections. It costs 0 tokens per session (7,771 once invoked), scanned A, original, Apache-2.0.

Project-specific guidance for writing Go code, based on conventions found in the project’s code reviews and contribution practices.

In plain words
What is it for?
Use it while changing Go code or reviewing a Go pull request, especially when deciding how to format errors and organize code.
Why use it?
It reduces inconsistent decisions about errors, names, structure, testing, architecture, comments, and documentation.

Agent

About the project

Canonical Copilot Collections is a repository for organizing and distributing GitHub Copilot instructions, prompts, agents, and skills across Canonical repositories. Teams configure repositories to subscribe to shared collections, such as Python, documentation, or Juju development guidance, and keep those assets synchronized.

canonical/copilot-collections · 29 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/canonical/copilot-collections/go-style-guide
Clone the repo
git clone --depth 1 https://github.com/canonical/copilot-collections

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for go-style-guide

README.md
[![agentmods](https://agentmods.dev/badge/agents/canonical/copilot-collections/go-style-guide.svg)](https://agentmods.dev/agents/canonical/copilot-collections/go-style-guide)
Your own site
<a href="https://agentmods.dev/agents/canonical/copilot-collections/go-style-guide"><img src="https://agentmods.dev/badge/agents/canonical/copilot-collections/go-style-guide.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 7,771 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.07771
Opus 5 $0.00000 $0.03886
Sonnet 5 $0.00000 $0.01554
Haiku 4.5 $0.00000 $0.00777

Measured 5d ago against content hash 54e1a81f17f8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

go-style-guide scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

assets/agents/go-style-guide.md · 1,484 lines

How it starts

The opening of the file, as written. The whole thing — 1,484 lines — stays where its author put it; the contents beside it link to each section on GitHub.

:orphan:

.. meta::
   :description: Go coding style guide covering error handling, naming
                 conventions, code structure, testing patterns, and architecture
                 principles derived from PR discussions and contribution standards.

Go coding style guide

This style guide documents Go-specific coding conventions used in the project. It captures patterns from code review discussions in merged PRs and established project standards. These guidelines complement general coding standards for your organization with project-specific decisions.

The guide is evidence-based, derived from actual PR discussions between maintainers (primarily @dmitry-lyfar and @jonathan-conder) during code reviews.


Error handling

Error message format

Pattern: Error messages start lowercase, contain no trailing punctuation, and follow the template: "what was attempted: why it went wrong".

Exception: Proper nouns (like "COMPONENT", "SERVICE") may start with a capital letter.

Rationale: Maintains consistency with existing error handling patterns and provides clear, actionable user guidance.

Good:

// From cmd/tool/connect.go
return fmt.Errorf("cannot connect plugs and slots across different environments")

// From cmd/tool/list.go
return fmt.Errorf("cannot list: \"--project\" incompatible with \"--global\"")

// From internal/daemon/api_environments.go
return statusBadRequest("project-id required")

Avoid:

return fmt.Errorf("Cannot connect plugs.") // Starts with capital, has punctuation
return fmt.Errorf("Error") // Not descriptive enough

Error specificity

Pattern: Return specific errors where possible to allow callers to handle them appropriately.

Good:

if _, err := os.Stat(path); err != nil {
    if os.IsNotExist(err) {
        // Handle file not found specifically
        return fmt.Errorf("configuration file %q not found", path)
    }
    return fmt.Errorf("cannot access configuration file %q: %w", path, err)
}

Read the full file on GitHub · 1,484 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 1,484 lines · 0 tokens per session scan A 54e1a81f17f8

Subscribe to this mod's changes

go-style-guide is an agent published in the GitHub repository canonical/copilot-collections (29 stars, last pushed 2d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 7,771 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories