Go Project Layout

How to structure a Go project as it grows, from a single main.go to internal packages and cmd folders for multiple binaries.

Go does not force a project layout, which is freeing and confusing at the same time. This section shows the path most Go projects follow as they grow.

Structuring a Go Project

start:   go.mod, main.go
grow:    + internal/store, internal/parser
several: + cmd/server, cmd/cli

Split packages by what they do, not by technical layer, and avoid utils and src/.

Folders are packages:

Do not create folders only to tidy files. Each one is a separate package.

The cmd Directory and Multiple Binaries

One folder per program under cmd/, thin main functions, and shared logic in internal/.

Summary

Start flat, add internal/ packages when parts have clear jobs, and add cmd/ when you build more than one program.

How to Structure a Go Project

A practical guide to Go project layout - start flat with main.go, split into packages by responsibility, use internal for private code, and avoid layouts copied from other languages.

The cmd Directory and Multiple Binaries in Go

How to build several programs from one Go module with cmd folders, keep main packages thin, and build or install each binary.