A small Go project often separates commands, packages, and documentation without needing a heavy framework.

layout Project layout should make the entry point and reusable code easy to find.

Project Layout

includeCmd
project_layout.go
Replay: real traced execution (multi-file project)
package main

import "fmt"

func main() {
	var includeCmd = true
	entries := []string{"README.md", "go.mod", "pkg/report"}
	if includeCmd {
		entries = append(entries, "cmd/report")
	}

	commandDirs := 0
	for _, entry := range entries {
		if len(entry) >= 4 && entry[:4] == "cmd/" {
			commandDirs++
		}
		fmt.Println("entry=", entry)
	}

	fmt.Println("entry_count=", len(entries))
	fmt.Println("command_dirs=", commandDirs)
}
package main

import "fmt"

func main() {
	var includeCmd = false
	entries := []string{"README.md", "go.mod", "pkg/report"}
	if includeCmd {
		entries = append(entries, "cmd/report")
	}

	commandDirs := 0
	for _, entry := range entries {
		if len(entry) >= 4 && entry[:4] == "cmd/" {
			commandDirs++
		}
		fmt.Println("entry=", entry)
	}

	fmt.Println("entry_count=", len(entries))
	fmt.Println("command_dirs=", commandDirs)
}
  1. includeCmd ← true, entries ← []string{"README.md", "go.mod", "pkg/report"}

    5func main() {6  var includeCmd→ true = true //@includeCmd=false7  entries→ []string{"README.md", "go.mod", "pkg/report"} := []string{"README.md", "go.mod", "pkg/report"}8  if includeCmd {
  2. entries ← []string{"README.md", "go.mod", "pkg/report", "cmd/report"}

    7entries := []string{"README.md", "go.mod", "pkg/report"}8if includeCmdtrue {9  entries→ []string{"README.md", "go.mod", "pkg/report", "cmd/report"} = append(entries, "cmd/report")10}
  3. commandDirs ← 0

    12commandDirs→ 0 := 013for _, entry := range entries {
  4. for _, entry := range entries

    pass 1 of 4
    12commandDirs := 013for _, entry"README.md" := range entries[]string{"README.md", "go.mod", "pkg/report", "cmd/report"} {14  if len(entry) >= 4 && entry[:4] == "cmd/" {15    commandDirs++16  }17  fmt.Println("entry=", entry"README.md")18}
    outputentry= README.md
    All 4 passes — pass 1 is the card above
    passentrycommandDirs
    1"README.md"
    2"go.mod"
    3"pkg/report"
    4"cmd/report"0 1
  5. commandDirs ← 1

    13for _, entry := range entries {14  if len(entry"cmd/report") >= 4 && entry[:4] == "cmd/" {15    commandDirs→ 1++16  }
  6. fmt.Println("entry=", entry)

    16  }17  fmt.Println("entry=", entry"cmd/report")18}
    outputentry= cmd/report
  7. fmt.Println("entry_count=", len(entries))

    20  fmt.Println("entry_count=", len(entries[]string{"README.md", "go.mod", "pkg/report", "cmd/report"}))21  fmt.Println("command_dirs=", commandDirs1)22}
    outputentry_count= 4
    command_dirs= 1
  1. includeCmd ← false, entries ← []string{"README.md", "go.mod", "pkg/report"}

    5func main() {6  var includeCmd→ false = false7  entries→ []string{"README.md", "go.mod", "pkg/report"} := []string{"README.md", "go.mod", "pkg/report"}8  if includeCmd {9    entries = append(entries, "cmd/report")10  }1112  commandDirs→ 0 := 013  for _, entry := range entries {
  2. for _, entry := range entries

    pass 1 of 3
    12commandDirs := 013for _, entry"README.md" := range entries[]string{"README.md", "go.mod", "pkg/report"} {14  if len(entry) >= 4 && entry[:4] == "cmd/" {15    commandDirs++16  }17  fmt.Println("entry=", entry"README.md")18}
    outputentry= README.md
    All 3 passes — pass 1 is the card above
    passentry
    1"README.md"
    2"go.mod"
    3"pkg/report"
  3. fmt.Println("entry_count=", len(entries))

    20  fmt.Println("entry_count=", len(entries[]string{"README.md", "go.mod", "pkg/report"}))21  fmt.Println("command_dirs=", commandDirs0)22}
    outputentry_count= 3
    command_dirs= 0