go-project-structure

Define standardized Go project layouts separating business logic from infrastructure.

Updated Mar 25, 2020
One-click install
npx skills add https://github.com/daominah/gostructure --skill go-project-structure-daominah
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-project-structure
Source: https://github.com/daominah/gostructure/tree/main/.claude/skills/go-project-structure
Command: npx skills add https://github.com/daominah/gostructure --skill go-project-structure-daominah

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a consistent, maintainable layout and package conventions to prevent tangled codebases where business logic and infrastructure are mixed, reducing onboarding friction and making testing and refactoring easier.

Core Features & Use Cases

  • Directory layout: Clear roles for cmd, pkg/model, pkg/logic, pkg/driver, pkg/base, config, web, and doc to separate concerns.
  • Conventions: Naming patterns, file placement, and package responsibilities that support testability and dependency inversion.
  • Use Case: Bootstrapping a new Go microservice or refactoring an existing codebase to follow clean architecture principles for easier testing and deployment.

Quick Start

Apply the go-project-structure guidelines to scaffold your repository, move domain models into pkg/model, implement business logic in pkg/logic behind interfaces, and place external integrations in pkg/driver.

Frequently Asked Questions about go-project-structure

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Go project to separate business logic from infrastructure?

To structure a Go project and separate business logic from infrastructure, use a standardized directory layout with clear package responsibilities. Place domain models in pkg/model, implement business logic in pkg/logic behind interfaces, and isolate external integrations in pkg/driver.

What is the best way to organize a Go microservice codebase for testability?

The best way to organize a Go microservice codebase for testability is applying clean architecture conventions. Define specific directory roles for cmd, pkg, and config to ensure modularity, support dependency inversion, and make refactoring easier.

How do I refactor an existing Go codebase to follow clean architecture conventions?

To refactor an existing Go codebase to clean architecture, move domain models into pkg/model, relocate business logic to pkg/logic behind interfaces, and shift external integrations to pkg/driver. This separation prevents tangled code and reduces onboarding friction.

When do I need a standardized Go project layout for my application?

You need a standardized Go project layout when creating new services, refactoring existing codebases, or preparing projects for testing and deployment. It prevents mixed business logic and infrastructure, ensuring predictable build artifacts and maintainable code.

Does the Go project structure convention support dependency inversion?

Yes, the Go project structure convention supports dependency inversion by defining specific package responsibilities and file placement. Implementing business logic in pkg/logic behind interfaces and placing external integrations in pkg/driver ensures modularity and testability.