The Standard Go Project Layout Debate

What Actually Works

Use a flat structure with cmd/ for apps, internal/ for private code, and pkg/ for public libraries to follow Go community standards.

There is no single mandated layout; the community standard is a flat structure with cmd/ for executables, internal/ for private packages, and pkg/ for public libraries. Place your main application entry point in cmd/myapp/main.go and your shared internal logic in internal/pkg/ to enforce visibility rules.

myproject/
  go.mod
  cmd/
    myapp/
      main.go
  internal/
    pkg/
      logic.go
  pkg/
    public/
      api.go