Community藝術與設計github.com

netresearch/go-development-skill

Agent Skill: Enterprise Go development patterns - resilient services, testing | Claude Code compatible

相容平台Claude Code~Codex CLI~Cursor
npx add-skill netresearch/go-development-skill

name: go-development description: "Use when developing Go applications, implementing job schedulers or cron, Docker API integrations, LDAP/AD clients, building resilient services with retry logic, setting up Go test suites (unit/integration/fuzz/mutation), running golangci-lint, or optimizing Go performance." license: "(MIT AND CC-BY-SA-4.0). See LICENSE-MIT and LICENSE-CC-BY-SA-4.0" compatibility: "Requires go 1.21+, golangci-lint, docker." metadata: author: Netresearch DTT GmbH version: "1.13.0" repository: https://github.com/netresearch/go-development-skill allowed-tools: Bash(go:) Bash(make:) Bash(docker:) Bash(golangci-lint:) Read Write Glob Grep

Go Development Patterns

Required Workflow

For reviews, invoke related skills: security-audit (OWASP), enterprise-readiness (OpenSSF/SLSA), github-project (branch protection). All are required.

Core Principles

Type Safety

  • Avoid: interface{} (use any), sync.Map, scattered type assertions, reflection
  • Prefer: Generics [T any], errors.AsType[T] (Go 1.26), concrete types
  • Run go fix ./... after upgrades

Consistency

  • One pattern per problem domain
  • Match existing codebase patterns
  • Refactor holistically or not at all
  • Config precedence: defaults < config file < env vars < flags

Testing

  • Build tags isolate test tiers: unit (default), integration, e2e
  • Always use t.Parallel(), t.Helper(), table-driven subtests
  • Use log/slog directly -- never wrap it in custom Logger interfaces

Conventions

  • Errors: lowercase, no punctuation (errors.New("invalid input"))
  • Naming: ID, URL, HTTP (not Id, Url, Http)
  • Error wrapping: fmt.Errorf("failed to process: %w", err)

References

Git hooks: ls lefthook.yml 2>/dev/null && lefthook install || echo "Add lefthook — see references/lefthook-template.md"

Load as needed:

ReferencePurpose
references/architecture.mdPackage structure, config management, middleware chains
references/logging.mdStructured logging with log/slog, migration from logrus
references/cron-scheduling.mdgo-cron patterns: named jobs, runtime updates, context, resilience
references/resilience.mdRetry logic, graceful shutdown, context propagation
references/docker.mdDocker client patterns, buffer pooling
references/ldap.mdLDAP/Active Directory integration
references/testing.mdTest strategies, build tags, table-driven tests
references/linting.mdgolangci-lint v2, staticcheck, code quality
references/api-design.mdBitmask options, functional options, builders
references/fuzz-testing.mdGo fuzzing patterns, security seeds
references/contracts-and-invariants.mdContracts, invariants, property tests
references/mutation-testing.mdGremlins configuration, test quality measurement
references/makefile.mdStandard Makefile interface for CI/CD
references/modernization.mdGo 1.26 modernizers, go fix, errors.AsType[T], wg.Go()
references/lefthook-template.mdReady-to-use lefthook.yml for Go project git hooks
references/reusable-workflows.mdReusable Actions workflow callers, permission propagation, release-gate outputs
references/single-build-release.mdSingle-build release: cross-compile once, reuse for release+container
references/awesome-go-submission.mdawesome-go submission: CI-parsed PR body, entry format, name collisions

Quality Gates

Run before completing any review:

golangci-lint run --timeout 5m    # Linting
go vet ./...                       # Static analysis
staticcheck ./...                  # Additional checks
govulncheck ./...                  # Vulnerability scan
go test -race ./...                # Race detection

Stdlib Vulnerability Fixes

When govulncheck reports stdlib vulnerabilities: check fix version via vuln.go.dev, update go X.Y.Z in go.mod, run go mod tidy. Use PR branches for repos with branch protection.


Contributing: Submit improvements to https://github.com/netresearch/go-development-skill

相關技能