golang-testing-patterns

golang-testing-patterns is a skill for Cursor from codeready-toolchain/tarsy. It costs 47 tokens per session (1,895 once invoked), scanned A, original, Apache-2.0.

A set of testing patterns for Go, the programming language. It covers table-driven tests, which run the same test logic against several named cases, and smaller subtests.

In plain words
What is it for?
It is for writing or reorganizing Go tests, checking error cases, improving test coverage, and using subtests or parallel test runs.
Why use it?
It gives tests a consistent structure and makes failures easier to identify and individual cases easier to run.

Skill for Cursor

Written for Cursor: installed under .cursor/.

Good fit It is for writing or reorganizing Go tests, checking error cases, improving test coverage, and using subtests or parallel test runs.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/codeready-toolchain/tarsy/golang-testing-patterns.svg)](https://agentmods.dev/skills/codeready-toolchain/tarsy/golang-testing-patterns)
Your own site
<a href="https://agentmods.dev/skills/codeready-toolchain/tarsy/golang-testing-patterns"><img src="https://agentmods.dev/badge/skills/codeready-toolchain/tarsy/golang-testing-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 47 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,895 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.00047 $0.01895
Opus 5 $0.00023 $0.00948
Sonnet 5 $0.00009 $0.00379
Haiku 4.5 $0.00005 $0.00189

Measured 7d ago against content hash 9eac58b03b0a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

golang-testing-patterns 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 7d 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-testing-patterns/SKILL.md · 332 lines

How it starts

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

Go Testing Patterns

Modern testing patterns for Go following 2025-2026 best practices.

Table-Driven Tests

The idiomatic Go approach for comprehensive testing.

Basic structure:

func TestFeature(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		expected int
		wantErr  bool
	}{
		{
			name:     "valid input",
			input:    "hello",
			expected: 5,
			wantErr:  false,
		},
		{
			name:     "empty input",
			input:    "",
			expected: 0,
			wantErr:  true,
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, err := ProcessString(tt.input)
			
			if tt.wantErr {
				if err == nil {
					t.Errorf("expected error, got nil")
				}
				return
			}
			
			if err != nil {
				t.Fatalf("unexpected error: %v", err)
			}
			
			if got != tt.expected {
				t.Errorf("got %d, want %d", got, tt.expected)
			}
		})
	}
}

Using Subtests with t.Run()

Benefits:

  • Clear failure messages showing which case failed
  • Can run specific tests: go test -run TestFeature/valid_input
  • Parallel execution support

Pattern:

for _, tt := range tests {
	t.Run(tt.name, func(t *testing.T) {
		t.Parallel() // Run subtests in parallel
		// ... test logic
	})
}

Test Organization

File structure:

  • Tests live alongside code: service.goservice_test.go
  • Integration tests in separate package: service_integration_test.go
  • Shared test utilities: test/util/ or testutil/

Test function naming:

// Unit tests
func TestSessionService_CreateSession(t *testing.T) {}
func TestSessionService_CreateSession_ValidationError(t *testing.T) {}

// Integration tests
func TestSessionService_Integration(t *testing.T) {}

Setup and Teardown

Using t.Cleanup():

func TestWithCleanup(t *testing.T) {
	// Setup
	db := setupTestDB(t)
	t.Cleanup(func() {
		db.Close() // Always runs, even if test fails
	})
	
	// Test logic
	// ...
}

Setup once for all subtests:

func TestSuite(t *testing.T) {
	// Shared setup
	db := setupTestDB(t)
	t.Cleanup(func() { db.Close() })
	
	t.Run("test1", func(t *testing.T) {
		// Uses shared db
	})
	
	t.Run("test2", func(t *testing.T) {
		// Uses shared db
	})
}

Read the full file on GitHub · 332 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. 7d ago First seen · 332 lines · 47 tokens per session scan A 9eac58b03b0a

Subscribe to this mod's changes

golang-testing-patterns is a skill published in the GitHub repository codeready-toolchain/tarsy (10 stars, last pushed 3d ago), licensed Apache-2.0. It adds 47 tokens to every session and 1,895 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.

Related

Other skills, from other repositories

temporal-python-testing

Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.

wshobson/agents · 45 tokens

python-testing

Guidelines for writing and running tests in the Agent Framework Python codebase. Use this when creating, modifying, or running tests.

microsoft/agent-framework · 29 tokens

unit-test

A Go testing workflow for writing unit tests: small tests that check individual functions or components. It supports table-driven cases, where many inputs and expected results are organised in one test, and subtests.

johnqtcg/awesome-skills · 100 tokens

fuzzing-test

A Go testing guide for generating fuzz tests, which repeatedly try varied inputs to find crashes and unexpected behavior. It first checks whether the code is suitable for fuzzing.

johnqtcg/awesome-skills · 74 tokens

test-go

Write, review, and improve Go test code for this project. Use whenever generating, reviewing, or modifying Go tests - including when invoked by the Tester agent, the /test prompt, or any test-related request. Covers table-driven tests, subtests, t.Parallel(), test helpers with t.Helper(), error assertions via…

sergeyklay/.agents · 109 tokens

go-testing-with-testify

Write, review, or harden Go tests using stretchr/testify assert, require, mock, or suite. Use for assertion choice, test doubles, subtests, concurrency, and flake triage in an existing Go test setup. Use coding-guidance-go for production code or non-testify tests and tester-mindset for test strategy without concrete…

n-n-code/n-n-code-skills · 79 tokens