go

Apply Go idioms, explicit error handling, and modular API design patterns.

Updated May 15, 2021
One-click install
npx skills add https://github.com/JustinFirsching/dotfiles --skill go-justinfirsching
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go
Source: https://github.com/JustinFirsching/dotfiles/tree/main/opencode/.config/opencode/skill/go
Command: npx skills add https://github.com/JustinFirsching/dotfiles --skill go-justinfirsching

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go developers struggle to adopt consistent idioms, handle errors robustly, and design reliable APIs; this skill codifies proven patterns to improve readability, maintainability, and correctness.

Core Features & Use Cases

  • Go idioms: explicit error handling, small interfaces, and composition
  • Error handling patterns: wrap errors, sentinel errors, and context
  • API design: package by feature, typed errors, and context propagation
  • Use Cases: building robust microservices, libraries, and CLI tools in Go

Quick Start

Create a small Go function that uses explicit error returns, wraps errors with context, and demonstrates dependency injection.

Frequently Asked Questions about go

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

FAQPage Schema
What is the best way to handle errors in Golang microservices?

Idiomatic Golang uses explicit error returns, small interfaces, and composition over inheritance. Adopting these patterns ensures code remains modular, readable, and maintainable across servers and CLI tools.

How do I propagate context in a Go API design?

To propagate context in Go API design, pass context.Context as the first argument in function signatures. This enforces context-aware functions, ensuring reliable cancellation and timeouts across server and library boundaries.

Why does Go prefer small interfaces over large ones?

Go prefers small interfaces to enforce composition and reduce coupling. Defining interfaces with only the required methods prevents unnecessary dependencies, ensuring modular and maintainable API designs.

Can I use typed errors and sentinel errors together in Golang?

Yes, you can use typed and sentinel errors together in Golang. Defining sentinel errors for expected values and wrapping them with typed context allows robust error matching while preserving the original error chain.

Does this approach apply to building CLI tools or just servers in Go?

This approach applies to building both CLI tools and servers in Go. Patterns for explicit error handling, context propagation, and modular API design are universally applicable across microservices, libraries, and command-line interfaces.