golang-project-layout

Organize Go projects with scalable single-module or multi-module directory structures.

Updated Mar 29, 2026
One-click install
npx skills add https://github.com/osmanozen/go-commerce --skill golang-project-layout-osmanozen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-project-layout
Source: https://github.com/osmanozen/go-commerce/tree/main/.agents/skills/golang-project-layout
Command: npx skills add https://github.com/osmanozen/go-commerce --skill golang-project-layout-osmanozen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a clear blueprint for structuring Go projects to scale from small tools to multi-module repos, avoiding over-structuring and misplacements.

Core Features & Use Cases

  • Guidance on when to use a single-module layout versus a multi-module workspace.
  • Clear recommendations for placing main packages under cmd/, organizing internal vs public code, and following module naming conventions.
  • Practical examples and decision points for migrating an existing repository to a scalable Go project layout.

Quick Start

Select your project type (CLI tool, library, service) and apply the recommended Go project layout from this Skill to initialize your repository.

Frequently Asked Questions about golang-project-layout

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

FAQPage Schema
How do I structure a scalable Golang project layout?

Structure a scalable Golang project by placing main packages under cmd/, separating internal code from public code, and aligning module names with repository URLs to enforce clean boundaries.

When should I use a single-module versus a multi-module workspace in Go?

Use a single-module Go layout for small tools and libraries, and adopt a multi-module workspace when you need to manage multiple independent components or versioned services within the same repository.

What is the difference between internal and pkg directories in a Go project?

The internal directory restricts code visibility to your own module, while the pkg directory exposes public code for external import, ensuring clear separation between private and public APIs.

How do I organize main packages in a Golang monorepo?

Organize main packages in a Golang monorepo by placing each executable under the cmd/ directory, co-locating code with tests to maintain a clean and scalable structure.

What is the best way to migrate an existing Go repository to a scalable layout?

Migrate an existing Go repository by evaluating project type, moving executables to cmd/, isolating private logic to internal/, and aligning module names with repository URLs for a scalable layout.

Why should module names match repository URLs in Go project architecture?

Module names should match repository URLs in Go architecture to ensure reliable imports, prevent naming collisions, and maintain clear mapping between the codebase and its remote source.