Get the FREE Ultimate OpenClaw Setup Guide →

go-development

npx machina-cli add skill netresearch/go-development-skill/go-development --openclaw
Files (1)
SKILL.md
3.3 KB

Go Development Patterns

When to Use

  • Building Go services or CLI applications
  • Implementing job scheduling or task orchestration
  • Integrating with Docker API
  • Building LDAP/Active Directory clients
  • Designing resilient systems with retry logic
  • Setting up comprehensive test suites

Required Workflow

For comprehensive reviews, ALWAYS invoke these related skills:

  1. Security audit - Invoke /netresearch-skills-bundle:security-audit for OWASP analysis, vulnerability assessment, and security patterns
  2. Enterprise readiness - Invoke /netresearch-skills-bundle:enterprise-readiness for OpenSSF Scorecard, SLSA compliance, supply chain security
  3. GitHub project setup - Invoke /netresearch-skills-bundle:github-project for branch protection, rulesets, CI workflow validation

A Go development review is NOT complete until all related skills have been executed.

Core Principles

Type Safety

  • Avoid: interface{} (use any), sync.Map, scattered type assertions, reflection, errors.As with pre-declared variables
  • Prefer: Generics [T any], errors.AsType[T] (Go 1.26), concrete types, compile-time verification
  • Modernize: Run go fix ./... after Go upgrades to apply automated modernizers

Consistency

  • One pattern per problem domain
  • Match existing codebase patterns
  • Refactor holistically or not at all

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

Load these as needed for detailed patterns and examples:

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/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()

Quality Gates

Run these checks 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

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

Source

git clone https://github.com/netresearch/go-development-skill/blob/main/skills/go-development/SKILL.mdView on GitHub

Overview

This skill provides practical patterns for building Go services and CLI tools, implementing job scheduling, Docker integrations, and LDAP clients, while prioritizing resilience, testing, and performance. It emphasizes type safety, consistency, and conventional practices to improve reliability and maintainability across Go projects.

How This Skill Works

The guidance centers on core principles (type safety, consistency, conventions) and reference patterns across architecture, logging, cron scheduling, resilience, docker, ldap, and testing. Reviews are guided by these patterns, with explicit workflows to invoke related skills like security audit, enterprise readiness, and GitHub project setup before completion.

When to Use It

  • Building Go services or CLI applications
  • Implementing job scheduling or task orchestration
  • Integrating with Docker API
  • Building LDAP/Active Directory clients
  • Designing resilient systems with retry logic and comprehensive test suites

Quick Start

  1. Step 1: Review core principles (type safety, consistency, conventions) and reference materials (architecture, logging, resilience, docker, ldap, testing)
  2. Step 2: Identify a domain in your project (service, scheduler, docker, or ldap) and apply a pattern aligned to that domain
  3. Step 3: Run quality gates: golangci-lint run, go vet ./..., staticcheck ./..., govulncheck ./..., go test -race ./...

Best Practices

  • Prefer generics over interface{} (use any) and avoid sync.Map; favor concrete types and explicit type checks
  • Wrap errors with fmt.Errorf("...: %w", err) and follow consistent error messaging conventions
  • Keep one pattern per problem domain and match existing codebase conventions
  • Run go fix ./... after Go upgrades to apply automated modernizers
  • Follow naming conventions (ID, URL, HTTP) and avoid nonstandard forms like Id, Url, Http

Example Use Cases

  • A Go service using cron-scheduling patterns for named jobs with runtime updates
  • A Docker API client integration optimized with buffer pooling for high-throughput calls
  • LDAP/Active Directory client performing bind and search operations with context-aware cancellation
  • A resilient API client implementing retry logic and graceful shutdown with context propagation
  • A comprehensive test suite employing table-driven tests, build tags, and race detection

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers