go-project-layout

Standardize Go project and module structure with cmd, internal, and pkg conventions.

130|8|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/sandgardenhq/sgai --skill go-project-layout-sandgardenhq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-project-layout
Source: https://github.com/sandgardenhq/sgai/tree/main/cmd/sgai/skel/.sgai/skills/coding-practices/go-project-layout
Command: npx skills add https://github.com/sandgardenhq/sgai --skill go-project-layout-sandgardenhq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It removes confusion around structuring Go modules and projects by providing a clear, modern layout with conventions for cmd, internal, pkg, testing, and build workflows.

Core Features & Use Cases

  • Module Initialization: Guidance on go mod init, managing go.mod versions, and dependency hygiene with tidy, verify, and graph.
  • Project Structures: Ready-to-use patterns for minimal apps, libraries, multi-binary applications, and full-scale services with cmd, internal, pkg, api, configs, scripts, and test directories.
  • Build and Testing Practices: Standard commands for build, run, cross-compilation, testing layouts, and a Makefile template to streamline common tasks.
  • Use Case: Starting a new web service with separate API server and worker binaries that share internal packages while keeping public APIs clean and versionable.

Quick Start

Ask to scaffold a new Go project with a cmd/myapp entrypoint, internal/server package, proper go.mod version, and a Makefile for build and test.

Frequently Asked Questions about go-project-layout

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

FAQPage Schema
What is the best way to structure a Go project with multiple binaries?

The standard Go project layout uses cmd for entrypoints, internal for private packages, and pkg for public libraries. This structure reduces setup errors by cleanly separating multi-binary applications from shared internal logic and versionable public APIs.

How do I organize Go modules and manage dependencies with go mod?

Organize Go modules by initializing with go mod init and maintaining dependency hygiene using tidy, verify, and graph commands. This establishes a clean go.mod file and ensures consistent dependency management across the project lifecycle.

When do I need internal versus pkg directories in a Go application?

Use the internal directory for private packages restricted to your module, and pkg for public libraries safe for external import. This Go project layout convention keeps public APIs clean and versionable while hiding implementation details.

How to set up a Makefile for Go cross-compilation and testing?

Set up a Makefile with standard build, run, cross-compilation, and testing commands to streamline Go project workflows. This provides a unified entry point for compiling target binaries across architectures and executing test suites consistently.

Does this Go project layout support modern Go version features and modules?

Yes, this Go project layout supports modern Go version features and module workflows. It provides guidance on go.mod version management and applies current conventions for initializing repositories and organizing dependencies.