go-coding-standards
БесплатноЗапускает вложенные скриптыНе проверенGo coding standards following idiomatic Go patterns, error handling, concurrency best practices, and modern Go tooling. Use for Go projects requiring clean…
Об этом скилле
Go Coding Standards
Quick Navigation: Level 1: Quick Start (5 min) → Level 2: Implementation (30 min) → Level 3: Mastery (Extended)
Level 1: Quick Start (<2,000 tokens, 5 minutes)
Core Principles
- Idiomatic Go: Write code that follows Go idioms - simple, clear, and effective
- Explicit Errors: Return errors explicitly, handle them properly, no exceptions
- Interfaces: Accept interfaces, return concrete types
- Concurrency: Goroutines and channels for concurrent operations
- Testing: Table-driven tests with >80% coverage
Essential Checklist
- Formatting: Code formatted with
gofmt, imports organized withgoimports - Naming: Follow Go conventions (MixedCaps, camelCase, short names in limited scope)
- Error Handling: All errors checked and wrapped with context
- Testing:
_test.gofiles with table-driven tests, benchmarks - Documentation: Package and exported function documentation
- Modules:
go.modwith semantic versioning, tidy dependencies - Linting: Pass
golangci-lintwith strict configuration - Security: Input validation, no hardcoded secrets, secure defaults
Quick Example
// Package auth provides user authentication services.
package auth
import (
"context"
"errors"
"fmt"
)
var (
// ErrInvalidCredentials indicates authentication failure.
ErrInvalidCredentials = errors.New("invalid credentials")
// ErrUserNotFound indicates user does not exist.
ErrUserNotFound = errors.New("user not found")
)
// User represents an authenticated user.
type User struct {
ID string
Username string
Email string
}
// Repository defines user storage operations.
type Repository interface {
FindByUsername(ctx context.Context, username string) (*User, error)
VerifyPassword(ctx context.Context, userID, password string) bool
}
// Service handles authentication operations.
type Service struct {
repo Repository
}
// NewService creates a new authentication service.
func NewService(repo Repository) *Service {
return &Service{repo: repo}
}
// Authenticate verifies credentials and returns the authenticated user.
//
// Returns ErrInvalidCredentials if authentication fails,
// ErrUserNotFound if user doesn't exist, or wrapped errors for other failures.
func (s *Service) Authenticate(ctx context.Context, username, password string) (*User, error) {
if username == "" || password == "" {
return nil, fmt.Errorf("username and password required")
}
user, err := s.repo.FindByUsername(ctx, username)
if err != nil {
if errors.Is(err, ErrUserNotFound) {
return nil, ErrInvalidCredentials // Don't reveal user existence
}
return nil, fmt.Errorf("find user: %w", err)
}
if !s.repo.VerifyPassword(ctx, user.ID, password) {
return nil, ErrInvalidCredentials
}
return user, nil
}
Quick Links to Level 2
- Code Style & Organization
- Error Handling Patterns
- Concurrency & Channels
- Testing Best Practices
- Performance Optimization
Level 2: Implementation (<5,000 tokens, 30 minutes)
Code Style & Organization
Idiomatic Go Naming
// ✅ Good: Clear, concise Go naming
type UserService struct {
db *sql.DB
cache Cache
}
func (s *UserService) Get(ctx context.Context, id string) (*User, error) {
// Short names in limited scope
u, err := s.cache.Get(ctx, id)
if err == nil {
return u, nil
}
return s.db.QueryUser(ctx, id)
}
// ❌ Bad: Verbose, non-idiomatic
type UserServiceInterface struct {
databaseConnection *sql.DB
cacheImplementation Cache
}
Package Structure
myapp/
├── cmd/
│ └── server/
│ └── main.go # Entry point
├── internal/
│ ├── auth/ # Authentication domain
│ │ ├── service.go
│ │ ├── repository.go
│ │ └── service_test.go
│ └── user/ # User domain
│ ├── user.go
│ └── postgres.go
├── pkg/
│ └── middleware/ # Reusable components
│ └── logging.go
├── go.mod
└── go.sum
Error Handling Patterns
Sentinel Errors and Wrapping
import (
"errors"
"fmt"
)
// Sentinel errors
var (
ErrNotFound = errors.New("not found")
ErrUnauthorized = errors.New("unauthorized")
ErrValidation = errors.New("validation failed")
)
// Custom error types
type ValidationError struct {
Field string
Message string
}
func (e *ValidationError) Error() string {
return fmt.Sprintf("%s: %s", e.Field, e.Message)
}
// Error wrapping with context
func (s *Service) GetUser(ctx context.Context, id string) (*User, error) {
user, err := s.repo.FindByID(ctx, id)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, fmt.Errorf("user %s: %w", id, ErrNotF
Установить go-coding-standards в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл go-coding-standards?
Go coding standards following idiomatic Go patterns, error handling, concurrency best practices, and modern Go tooling. Use for Go projects requiring clean, efficient, production-ready code with comprehensive testing.
Как установить скилл go-coding-standards?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл go-coding-standards запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic