Go Backend Structure

Purpose

This document explains why a standard Go backend is structured the way it is and what belongs where.


1. Core Principles (Remember These)


2. High-Level Folder Layout

api-go/
├── cmd/
│   └── server/
│       └── main.go
│
├── internal/
│   ├── routes/
│   ├── handlers/
│   ├── models/
│   ├── db/
│   └── middleware/
│
├── go.mod
└── go.sum


3. cmd/ — Runnable Applications

Purpose:

Contains all executable entry points.

Rules: