mock-generation

Generate Go interface mocks with mockgen into a mocks/ subdirectory.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/d3fvxl/.dotfiles --skill mock-generation-d3fvxl
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mock-generation
Source: https://github.com/d3fvxl/.dotfiles/tree/main/config/opencode/skills/go-mocks
Command: npx skills add https://github.com/d3fvxl/.dotfiles --skill mock-generation-d3fvxl

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automatically generate mocks for Go interfaces using mockgen from the go.uber.org/mock package to simplify testing and reduce boilerplate code.

Core Features & Use Cases

  • Generate mocks from interfaces using mockgen
  • Place mocks in a mocks/ subdirectory of the package containing the interface
  • Run go generate ./... from the module root to regenerate all mocks

Quick Start

Run go generate ./... from the module root to regenerate all mocks.

Frequently Asked Questions about mock-generation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I auto-generate Go mocks for interfaces using mockgen?▼

To auto-generate Go mocks for interfaces, use mockgen from the go.uber.org/mock package and run go generate ./... from the module root to create mocks in a mocks/ subdirectory.

When do I need to regenerate mocks for Go interfaces?▼

You need to regenerate mocks for Go interfaces when new interfaces are added, existing interface signatures change, or tests require isolated mocks across domain packages.

Do I need to install mockgen to generate mocks for Go interfaces?▼

Yes, you need to install mockgen from the go.uber.org/mock package to generate Go mocks for interfaces and streamline unit testing.

What is the best way to organize generated mock files in a Go project?▼

The best way to organize generated mock files is to place them in a mocks/ subdirectory within the package containing the interface, allowing centralized regeneration via go generate ./... from the module root.

How does generating mocks for Go interfaces reduce boilerplate code?▼

Generating mocks for Go interfaces reduces boilerplate code by automating the creation of mock implementations, eliminating the need to manually write test doubles for unit testing.