golang-code-style

Enforces Go code style conventions for line breaking, declarations, control flow, and function design.

1|Updated May 25, 2020
One-click install
npx skills add https://github.com/titaneric/dotfiles --skill golang-code-style-titaneric
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-code-style
Source: https://github.com/titaneric/dotfiles/tree/main/dot_agents/skills/golang-code-style
Command: npx skills add https://github.com/titaneric/dotfiles --skill golang-code-style-titaneric

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go linters handle formatting, but clarity rules like early returns, named boolean conditions, non-nil collections, and value-vs-pointer parameter choices require judgment. This Skill encodes those judgment-based style rules so AI agents write and review Go code that stays readable and idiomatic. ## Core Features & Use Cases - Style Rule Enforcement: Covers line breaking at semantic boundaries, var vs := intent signaling, non-nil slice/map initialization, named struct fields, early returns, switch over if-else chains, and options structs for long parameter lists. - Code Review Guidance: Supports parallelized style reviews across large codebases using up to 5 sub-agents, each covering an independent style concern. - Use Case: When asked to write a function with 10 parameters or deeply nested validation, the Skill overrides the literal request and produces an options struct with early returns instead, keeping the happy path at minimal indentation. ## Quick Start Review this Go file for style issues and rewrite any nested validation logic using early returns and named boolean conditions.

Frequently Asked Questions about golang-code-style

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

FAQPage Schema
How do I enforce Go code style beyond what linters check?

Linters like gofmt and revive handle formatting, but clarity rules need judgment. This Skill covers early returns, named boolean conditions, non-nil collections, and options structs, and can orchestrate parallel sub-agents to review large codebases.

When should I use var versus := in Go variable declarations?

Use := for non-zero values and var for zero-value initialization, since the form signals intent. For example, var count int means the value starts at zero, while name := "default" indicates a meaningful initial value.

Should Go function parameters be pointers or values?

Pass small types like string, int, bool, and time.Time by value. Use pointers when the function mutates the argument, the struct exceeds roughly 128 bytes, or nil is meaningful for optional parameters.

Why should Go slices and maps never be returned as nil?

Nil maps panic on write, and nil slices serialize to null in JSON instead of [], surprising API consumers. Always initialize with []T{} or make() so empty collections behave predictably for callers.

What Go style topics does this Skill not cover?

It excludes naming conventions, linter configuration, and doc comments, which are handled by the sibling golang-naming, golang-lint, and golang-documentation skills. It focuses only on clarity rules requiring human judgment.