writing-modern-go

Migrate legacy Go patterns to modern idioms for Go 1.18 through 1.26.

1|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/fascari/ai-config --skill writing-modern-go
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-modern-go
Source: https://github.com/fascari/ai-config/tree/main/skills/writing-modern-go
Command: npx skills add https://github.com/fascari/ai-config --skill writing-modern-go

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Use when writing or reviewing Go code to ensure modern idioms are used instead of legacy patterns. Covers Go 1.18 through 1.26 features including slices, maps, cmp, errors.AsType, new(val), and wg.Go.

Core Features & Use Cases

  • Modern idiom modernization guidance across Go versions.
  • Conversions of legacy patterns to modern equivalents (e.g., errors.As to errors.AsType, wg.Add+go to wg.Go).
  • Real-world scenario: migrating code in a large codebase to Go 1.26.

Quick Start

Review the examples and refactor your codebase to use modern Go idioms up to Go 1.26.

Frequently Asked Questions about writing-modern-go

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

FAQPage Schema
How do I refactor legacy Go code to use modern idioms?

Modern Go refactoring converts legacy patterns like errors.As to errors.AsType and wg.Add+go to wg.Go. This updates codebases to use idioms available across Go versions 1.18 through 1.26.

What is the modern Go idiom for pointer initialization?

The modern Go idiom for pointer initialization is using new(T{...}). This replaces older pointer allocation patterns to align with contemporary Go 1.18 through 1.26 coding standards.

How does errors.AsType improve Go error handling?

errors.AsType improves Go error handling by replacing legacy errors.As patterns. It provides a modernized approach to type assertion within error chains for Go 1.18 through 1.26 codebases.

Can I use modern Go idioms in a large codebase migration?

Yes, modern Go idioms are designed for large codebase migrations. You can refactor modules incrementally, adopting features like slices, maps, cmp, and wg.Go up to Go 1.26.

Does this Go refactoring approach work across different module versions?

Yes, this refactoring approach works across module versions by aligning with the project's specific Go version. It targets features incrementally from Go 1.18 through 1.26.

When should I migrate from wg.Add and go routines to wg.Go?

You should migrate to wg.Go when adopting modern Go concurrency idioms. It replaces the legacy wg.Add+go pattern, streamlining goroutine management in Go 1.18 through 1.26 projects.