go
Use when the user asks about Go modules, go build, goroutines, channels, context cancellation, errors.Is/As, Go testing and fuzzing, govulncheck or a Go…
от j4flmao★ 47 звёзд на GitHub
Установить go в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Go
Purpose
Guide for Go build tools, module management, concurrency patterns, interface design, error handling, testing, and production deployment.
Agent Protocol
Trigger
Keywords: go build, go mod, goroutine, channel, interface go, error handling go, testing go, go generate, go tool, context, go concurrency.
Input Context
- Project type (CLI tool, web API, microservice, library)
- Go version
- Module organization (monorepo vs multi-module)
- Deployment target
Output Artifact
Code, go.mod/build commands, or a review of existing Go code. No file unless requested.
Response Format
Go version: {1.x}
Change: {what and why}
Code: {snippet}
Verify: go vet ./... && go test -race ./... && govulncheck ./...
Decision Trees
Project Structure
What kind of project?
├── CLI tool → Single main.go + internal packages, cmd/ layout
├── Web API / microservice → cmd/ (entrypoints) + internal/ (private) + pkg/ (shared)
├── Library → Exported API surface minimal, no internal, flat or by feature
├── Monorepo → go.work file, multiple modules, shared tooling
└── gRPC service → protobuf codegen in separate package, buf tool
Concurrency Strategy
Workload type?
├── I/O bound (HTTP, DB, file) → Goroutines + channels / errgroup
├── CPU bound (compute, transform) → goroutines capped at runtime.NumCPU()
├── Fan-out / fan-in → worker pool with channel, sync.WaitGroup
├── Pipeline (producer → transform → consumer) → channels for each stage
├── Timeout / cancellation → context.Context with deadline/timeout
└── Once-only init → sync.Once for thread-safe lazy init
Error Handling
Error strategy?
├── Expected errors (validation, not found) → return error type, callers handle
├── Unexpected errors (network, IO) → wrap with fmt.Errorf("%w: %v", sentinel, err)
├── Retryable errors → errors.Is + retry with backoff
├── Panic → only for programmer errors (nil deref, bounds); recover in goroutine top
└── Deferred cleanup → defer mu.Unlock(), defer file.Close(), defer db.Rollback()
Build & Module Management
Module Initialization
go mod init github.com/org/myproject
go mod tidy # Clean dependencies
go mod verify # Verify checksums
go mod download # Pre-download for Docker
go work init ./cmd ./pkg # Monorepo workspace
go.mod Conventions
module github.com/org/myproject
go 1.22
require (
github.com/gin-gonic/gin v1.9.1
go.uber.org/zap v1.27.0
golang.org/x/sync v0.7.0
)
// replace directive for local development
replace github.com/org/internal => ../internal
Build Commands
go build -o bin/server ./cmd/server
go build -ldflags="-X main.Version=v1.0.0" ./cmd/server
go test -race -count=1 ./...
go vet ./...
go generate ./...
Language-Specific Patterns
Interface Design (Accept Interfaces, Return Structs)
// Define small interfaces (1-3 methods)
type Storer interface {
Store(ctx context.Context, key string, value []byte) error
Load(ctx context.Context, key string) ([]byte, error)
}
// Implement with concrete struct
type S3Storer struct {
bucket string
client *s3.Client
}
// Accept interface, return struct
func NewHandler(s Storer) *Handler {
return &Handler{store: s}
}
Context Cancellation
func FetchWithTimeout(ctx context.Context, url string) ([]byte, error) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
req, _ := http.NewRequestWithContext(ctx, "GET", url, nil)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, fmt.Errorf("fetch %s: %w", url, err)
}
defer resp.Body.Close()
return io.ReadAll(resp.Body)
}
Worker Pool Pattern
func WorkerPool(ctx context.Context, jobs <-chan Job, results chan<- Result, workers int) {
var wg sync.WaitGroup
for range workers {
wg.Add(1)
go func() {
defer wg.Done()
for job := range jobs {
select {
case <-ctx.Done():
return
case results <- process(job):
}
}
}()
}
wg.Wait()
close(results)
}
Graceful Shutdown
func main() {
srv := &http.Server{Addr: ":8080", Handler: router}
go func() {
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatal(err)
}
}()
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
srv.Shutdown(ctx)
}
Error Wrapping and Inspection
import "errors"
// Sentinel errors
var ErrNotFound = errors.New("not found")
// Wrap with context
func GetUser(id int) (*User, error) {
user, err := db.QueryUser(id)
if errors.Is(err, sql.ErrNoRows) {
return
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/context-cancellation.md
- references/design-patterns-generics.md
- references/generics-compiler-internals.md
- references/generics-constraints-typesets.md
- references/generics-functional-patterns.md
- references/go-advanced.md
- references/go-fundamentals.md
- references/go-http-server.md
- references/testing-benchmarking.md
FAQ
Что делает скилл go?
Use when the user asks about Go modules, go build, goroutines, channels, context cancellation, errors.Is/As, Go testing and fuzzing, govulncheck or a Go service in production. Produces idiomatic Go with tests and toolchain setup. Not for Go web service architecture (use golang-architecture) or Kubernetes operators (use devops-kubernetes-operators).
Как установить скилл go?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл go запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
AnthropicThe scan that the plugin's GitHub Action runs.
azure-static-web-apps
GitHubHelps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
ai-ready
GitHubMake any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
aws-cdk-python-setup
GitHubSetup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…