golang-error-handling

golang-error-handling is a skill for Cursor from codeready-toolchain/tarsy. It costs 43 tokens per session (2,832 once invoked), scanned A, original, Apache-2.0.

A set of guidance for handling errors in Go programs, including adding context, defining error types, and checking whether errors match known conditions. Go is a programming language that reports many failures through returned error values.

In plain words
What is it for?
Use it when writing Go error flows, wrapping errors with context, defining custom or sentinel errors, and checking them with errors.Is or errors.As.
Why use it?
It reduces hidden failures and makes errors easier to understand and handle at the right level. It also supports reliable checks for cases such as missing records or invalid input.

Skill for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when writing Go error flows, wrapping errors with context, defining custom or sentinel errors, and checking them with errors.Is or errors.As.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/codeready-toolchain/tarsy/golang-error-handling
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.

Any agent
npx skills add codeready-toolchain/tarsy --skill golang-error-handling
Clone the repo
git clone --depth 1 https://github.com/codeready-toolchain/tarsy

Made for: Cursor.

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 golang-error-handling

README.md
[![agentmods](https://agentmods.dev/badge/skills/codeready-toolchain/tarsy/golang-error-handling/github.svg)](https://agentmods.dev/skills/codeready-toolchain/tarsy/golang-error-handling)
Your own site
<a href="https://agentmods.dev/skills/codeready-toolchain/tarsy/golang-error-handling"><img src="https://agentmods.dev/badge/skills/codeready-toolchain/tarsy/golang-error-handling/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for golang-error-handling

Your own site · 80×15
<a href="https://agentmods.dev/skills/codeready-toolchain/tarsy/golang-error-handling"><img src="https://agentmods.dev/badge/skills/codeready-toolchain/tarsy/golang-error-handling.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,832 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00043 $0.02832
Opus 5 $0.00022 $0.01416
Sonnet 5 $0.00009 $0.00566
Haiku 4.5 $0.00004 $0.00283

Measured 10d ago against content hash 37a19a37092e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

golang-error-handling 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 10d 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.

.cursor/skills/golang-error-handling/SKILL.md · 491 lines

How it starts

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

Go Error Handling

Modern error handling patterns for Go following 2025-2026 best practices.

Basic Error Handling

Always check errors:

result, err := doSomething()
if err != nil {
	return fmt.Errorf("operation failed: %w", err)
}

Never ignore errors (unless explicitly documented):

// Bad
doSomething()

// Good - explicit discard when safe
_ = file.Close()

// Good - handle in defer with function
defer func() {
	if err := file.Close(); err != nil {
		log.Printf("failed to close file: %v", err)
	}
}()

Error Wrapping

Use %w to wrap errors:

func GetUser(id string) (*User, error) {
	user, err := db.Query(id)
	if err != nil {
		return nil, fmt.Errorf("failed to get user %s: %w", id, err)
	}
	return user, nil
}

Unwrap errors with errors.Is() and errors.As():

err := GetUser("123")
if errors.Is(err, sql.ErrNoRows) {
	// Handle not found
}

var validationErr *ValidationError
if errors.As(err, &validationErr) {
	// Handle validation error
	fmt.Printf("field: %s, message: %s", validationErr.Field, validationErr.Message)
}

Sentinel Errors

Define package-level error values:

package services

import "errors"

var (
	ErrNotFound      = errors.New("resource not found")
	ErrAlreadyExists = errors.New("resource already exists")
	ErrInvalidInput  = errors.New("invalid input")
	ErrConflict      = errors.New("resource conflict")
	ErrUnauthorized  = errors.New("unauthorized")
)

Check with errors.Is():

session, err := service.GetSession(ctx, id)
if errors.Is(err, services.ErrNotFound) {
	return http.StatusNotFound, "session not found"
}
if err != nil {
	return http.StatusInternalServerError, "internal error"
}

Custom Error Types

For errors needing additional context:

type ValidationError struct {
	Field   string
	Message string
}

func (e *ValidationError) Error() string {
	return fmt.Sprintf("validation error: %s %s", e.Field, e.Message)
}

func NewValidationError(field, message string) error {
	return &ValidationError{Field: field, Message: message}
}

// Usage
if req.SessionID == "" {
	return nil, NewValidationError("session_id", "required")
}

Read the full file on GitHub · 491 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. 10d ago First seen · 491 lines · 43 tokens per session scan A 37a19a37092e

Subscribe to this mod's changes

golang-error-handling is a skill published in the GitHub repository codeready-toolchain/tarsy (10 stars, last pushed today), licensed Apache-2.0. It adds 43 tokens to every session and 2,832 once invoked, about $0.0002 per session on Opus 5. 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-31.