Go 1.25+ Standards

Enforce Go 1.25+ standards with error wrapping, table-driven tests, and golangci-lint.

115|8|Updated Mar 30, 2025
One-click install
npx skills add https://github.com/Goldziher/spikard --skill go-1-25-standards
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Go 1.25+ Standards
Source: https://github.com/Goldziher/spikard/tree/main/.ai-rulez/skills/go-125-standards
Command: npx skills add https://github.com/Goldziher/spikard --skill go-1-25-standards

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enforces modern Go programming standards, ensuring code quality, maintainability, and robustness for Go 1.25 and later versions.

Core Features & Use Cases

  • Modern Go Features: Utilizes error wrapping (fmt.Errorf("%w", err)) and errors.Is/As for robust error handling.
  • Testing Standards: Implements table-driven tests with t.Run() and black-box testing conventions for *_test.go files.
  • Linting & Analysis: Integrates golangci-lint with essential linters like errcheck, govet, staticcheck, gosec, and complexity checks (≤25 cyclomatic complexity).
  • Code Coverage: Aims for 80%+ coverage on business logic and uses go test -race for concurrency bug detection.
  • Package Structure: Adheres to standard Go project layout (cmd/, internal/, pkg/).
  • Naming Conventions: Follows PascalCase for types, camelCase for variables, and SCREAMING_SNAKE_CASE for constants.
  • Context Propagation: Ensures Context.Context is the first parameter in I/O functions and respects cancellation.
  • Structured Logging: Uses zerolog for efficient, structured logging.
  • Use Case: Ensure all new Go projects adhere to the latest industry best practices for error handling, testing, and code structure, reducing technical debt and improving collaboration.

Quick Start

Apply the Go 1.25+ Standards to a Go project to ensure best practices are followed.

Frequently Asked Questions about Go 1.25+ Standards

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

FAQPage Schema
How do I enforce modern Go best practices for error handling and testing?

Modern Go best practices are enforced by utilizing error wrapping with fmt.Errorf("%w", err) and errors.Is/As, implementing table-driven tests with t.Run(), and maintaining standard package structure to ensure code robustness.

What is the best way to structure a Go project to follow standard layout conventions?

The best way to structure a Go project is adhering to the standard Go project layout using cmd/, internal/, and pkg/ directories, while following PascalCase for types, camelCase for variables, and SCREAMING_SNAKE_CASE for constants.

How do I set up golangci-lint to check cyclomatic complexity and security in Go?

Set up golangci-lint by integrating essential linters like errcheck, govet, staticcheck, and gosec. Configure complexity checks to maintain a cyclomatic complexity of 25 or less for robust code analysis and security.

Does this approach support structured logging and context propagation in Go 1.25?

Yes, this approach supports structured logging using zerolog and ensures context propagation by requiring Context.Context as the first parameter in I/O functions, fully respecting cancellation for modern Go 1.25+ standards.

How do I write table-driven tests in Go with race condition detection?

Write table-driven tests in Go using t.Run() for subtests and black-box testing conventions for *_test.go files. Execute tests using go test -race to detect concurrency bugs and aim for 80%+ code coverage on business logic.

Can I use this to reduce technical debt in existing Go projects?

Yes, you can reduce technical debt in existing Go projects by applying these modern standards to refactor package structure, update error handling, and enforce linting rules, improving overall code maintainability and collaboration.