go-project-layout

Guide Go module structure and project organization patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear, standardized guidelines and examples for organizing Go projects, ensuring maintainability, scalability, and adherence to best practices.

Core Features & Use Cases

  • Module Initialization: Guides on setting up go.mod for new projects.
  • Standard Directory Structures: Illustrates layouts for minimal, application, library, and full-application projects.
  • Directory Conventions: Explains the purpose and usage of directories like /cmd, /internal, and /pkg.
  • Package Organization: Best practices for naming, structure, and import paths.
  • Build & Cross-Compilation: Commands for building, installing, and compiling for different platforms.
  • Testing Structure: Guidance on placing test files and data.
  • Makefile Example: A sample Makefile for common build tasks.

Quick Start

Use the go-project-layout skill to generate a standard directory structure for a new Go application project.

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 Golang project for scalability?

Organize a Go project using `/cmd` for entry points and `/internal` for private code to ensure maintainability. Standard layouts separate applications and libraries for clear package boundaries and scalable codebases.

How do I initialize a Go module and set up the project layout?

Initialize a Go module by creating a `go.mod` file, then apply a standard directory layout. Use `/pkg` for public libraries and `/internal` for private application code to enforce import path boundaries.

When should I use the /internal directory in my Go module layout?

Use the `/internal` directory in your Go module layout to restrict imports of private packages. Go enforces this boundary, preventing external modules from importing your internal application code.

How do I organize Go test files and test data in a standard project?

Place Go test files alongside the source code they test within the same directory. Store test data in a dedicated folder to maintain a clean project structure and streamline build commands.

Does this Go project structure guidance cover cross-compilation and build commands?

Yes, this Go project structure guidance covers build commands and cross-compilation for different platforms. It includes Makefile examples to automate common build and installation tasks.

Can I use this directory convention for both Go libraries and full applications?

Yes, you can use these directory conventions for both Go libraries and full applications. The guidelines illustrate distinct standard layouts tailored for minimal, application, and library projects.