go-dev-guidelines

Go Development Guidelines

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "go-dev-guidelines" with this command: npx skills add jumppad-labs/jumppad/jumppad-labs-jumppad-go-dev-guidelines

Go Development Guidelines

Overview

This skill provides comprehensive guidelines for idiomatic Go development with a Test-Driven Development (TDD) approach. Follow these patterns when writing Go code, creating tests, organizing projects, or refactoring existing code.

Quick Start Checklists

New Go Feature Checklist

When implementing a new feature in an existing Go project:

  • Define interface - Create small, focused interface in appropriate package

  • Write tests first - Create *_test.go file with testify/require tests

  • Generate mocks - Use mockery to generate mocks in mocks/ subfolder

  • Implement logic - Write the implementation to satisfy tests

  • Handle errors - Ensure all errors are explicitly handled

  • Add integration tests - Test the feature end-to-end if applicable

  • Run go vet & gofmt - Ensure code meets Go standards

  • Update documentation - Add godoc comments for exported types/functions

New Go Service/Package Checklist

When creating a new Go service or package from scratch:

  • Setup project structure - Use standard Go layout (/cmd , /internal , /pkg )

  • Initialize module - Run go mod init with appropriate module path

  • Define core interfaces - Start with small, focused interfaces

  • Write tests first - Follow TDD approach for all business logic

  • Implement with DI - Use dependency injection for testability

  • Add logging - Include structured logging for observability

  • Configure graceful shutdown - Implement proper cleanup for services

  • Document package - Add package-level godoc and README

Core Principles

Follow these seven core principles for all Go development:

  1. Follow Test-Driven Development (TDD)

Write tests before implementation. Tests should be easy to read and favor verbosity over abstraction.

  1. Use testify/require for Unit Tests

All unit tests must use github.com/stretchr/testify/require for assertions.

  1. Use Mockery for Mocks

Generate mocks using mockery. Mocks must be localized in a mocks/ subfolder next to the interface being mocked.

  1. Never Use Table-Driven Tests

Avoid table-driven tests. Write explicit test functions for each scenario.

  1. Never Mix Positive and Negative Tests

Keep positive (success) and negative (error) test cases in separate test functions.

  1. Handle All Errors Explicitly

Never ignore errors. Always handle them explicitly or return them to the caller.

  1. Prefer Small, Focused Interfaces

Design interfaces with few methods. Use composition over large interfaces.

  1. Use any Instead of interface{}

For generic types, prefer any over interface{} (Go 1.18+).

Standard Go Directory Structure

project-root/ ├── cmd/ # Main applications │ └── myapp/ │ └── main.go ├── internal/ # Private application code │ ├── handler/ # HTTP handlers │ │ ├── handler.go │ │ ├── handler_test.go │ │ └── mocks/ # Mocks for handler interfaces │ ├── service/ # Business logic │ │ ├── service.go │ │ ├── service_test.go │ │ └── mocks/ │ └── repository/ # Data access │ ├── repository.go │ ├── repository_test.go │ └── mocks/ ├── pkg/ # Public library code │ └── client/ │ ├── client.go │ ├── client_test.go │ └── mocks/ ├── api/ # API definitions (OpenAPI, protobuf) ├── configs/ # Configuration files ├── go.mod ├── go.sum └── README.md

Quick Reference

Common Test Patterns

// Unit test with mock func TestServiceCreate(t *testing.T) { mockRepo := mocks.NewRepository(t) mockRepo.On("Save", mock.Anything).Return(nil)

svc := NewService(mockRepo)
err := svc.Create(context.Background(), data)

require.NoError(t, err)
mockRepo.AssertExpectations(t)

}

// Separate negative test func TestServiceCreate_RepoError(t *testing.T) { mockRepo := mocks.NewRepository(t) mockRepo.On("Save", mock.Anything).Return(errors.New("db error"))

svc := NewService(mockRepo)
err := svc.Create(context.Background(), data)

require.Error(t, err)
require.Contains(t, err.Error(), "db error")

}

Naming Conventions

  • Packages: Short, lowercase, no underscores (handler , service )

  • Files: Lowercase with underscores (user_service.go , user_service_test.go )

  • Types: PascalCase (UserService , HTTPHandler )

  • Functions/Methods: PascalCase for exported, camelCase for unexported

  • Interfaces: Often end with -er suffix (Reader , Writer , UserRepository )

Navigation Table

Use this table to find detailed guidance for specific tasks:

If You Need To... See This Resource

Set up a new Go project structure Project Structure

Understand Go naming conventions Naming Conventions

Write tests with TDD, testify/require, and mockery Testing Guide

Organize packages, interfaces, and dependencies Code Organization

Handle errors idiomatically Error Handling

Work with goroutines, channels, and context Concurrency Patterns

Manage dependencies and go.mod Dependencies

See complete working examples Complete Examples

Resources

This skill includes detailed reference documentation in the references/ directory. Claude will load these resources as needed when working on specific tasks.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

implementation-planner

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

Funnel Builder

Builds complete multi-channel revenue funnels adapted to any business model. Combines proven frameworks from elite operators: Yomi Denzel's viral top-of-funn...

Registry SourceRecently Updated
Coding

Decode

Decode - command-line tool for everyday use

Registry SourceRecently Updated
Coding

Wip Release

One-command release pipeline. Bumps version, updates changelog + SKILL.md, publishes to npm + GitHub.

Registry SourceRecently Updated