go-best-practices

Enforces Go project structure, style, conventions, and Mage build system integration.

Updated Dec 3, 2023
One-click install
npx skills add https://github.com/ealvar3z/dotfiles --skill go-best-practices-ealvar3z
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-best-practices
Source: https://github.com/ealvar3z/dotfiles/tree/main/prompts/skills/go-best-practices
Command: npx skills add https://github.com/ealvar3z/dotfiles --skill go-best-practices-ealvar3z

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps ensure Go projects adhere to established best practices for structure, style, and conventions, leading to more maintainable and robust code.

Core Features & Use Cases

  • Code Structure Enforcement: Guides binary, internal code, and version management.
  • Style and Convention Adherence: Promotes consistent formatting, naming, and error handling.
  • Dependency Management: Encourages dependency injection and proper use of context.Context.
  • Testing and Robustness: Advocates for table-driven tests and avoiding panic.
  • Build System Integration: Recommends using Mage for build, install, and test targets.
  • Use Case: Integrate this skill into your Go project's CI/CD pipeline to automatically flag or fix deviations from best practices during code reviews.

Quick Start

Apply the go-best-practices skill to ensure the current Go project follows established conventions for file layout and error handling.

Frequently Asked Questions about go-best-practices

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

FAQPage Schema
How do I enforce Go best practices for project structure and error handling in my codebase?

To enforce Go best practices, apply rules for file layout order, error wrapping, context usage, and project structure standards. This ensures consistent formatting, naming, and interface design across your codebase for improved maintainability.

What is the recommended file layout order and project structure for a Go application?

The recommended Go project structure separates binary, internal code, and version management. Adhering to file layout order and project structure standards guides dependency injection and semantic receiver preferences for robust code.

How do I integrate Go code quality checks into a CI/CD pipeline using Mage?

Integrate Go code quality checks by using Mage for build, install, and test targets. This build system integration automatically flags or fixes deviations from conventions like table-driven tests and proper context usage during code reviews.

Does this approach to Go code review support dependency injection and context usage?

Yes, this Go code review approach explicitly encourages dependency injection and proper use of context.Context. It also advocates for avoiding panic and implementing table-driven tests to ensure robustness and consistent style.

What's the best way to standardize Go naming conventions and interface design across a team?

The best way to standardize Go naming and interface design is enforcing style and convention adherence. Applying rules for semantic receiver preferences, documentation, and formatting yields consistent, maintainable code.