Skip to content

refactor: reorganize into idiomatic Go project layout#87

Merged
timvw merged 1 commit into
mainfrom
refactor/idiomatic-go-layout
Apr 8, 2026
Merged

refactor: reorganize into idiomatic Go project layout#87
timvw merged 1 commit into
mainfrom
refactor/idiomatic-go-layout

Conversation

@timvw
Copy link
Copy Markdown
Owner

@timvw timvw commented Apr 8, 2026

Summary

  • Restructure flat package main into idiomatic Go CLI layout: cmd/ package for cobra commands, internal/color/ and internal/fuzzy/ for reusable utilities, and a slim main.go entry point
  • Extract color utilities and fuzzy matching into dedicated internal packages with exported APIs
  • Update goreleaser ldflags from main.version to cmd.Version

What changed

wt/
├── main.go                    # 6 lines: just calls cmd.Execute()
├── cmd/                       # all cobra commands + CLI logic
│   ├── root.go                # rootCmd, Execute(), init/flag setup
│   ├── checkout.go, create.go, ...
│   └── *_test.go
├── internal/
│   ├── color/                 # ANSI color support (Colorize, IsEnabled)
│   └── fuzzy/                 # fuzzy matching for interactive selectors
├── e2e/                       # (unchanged)
└── docs/                      # (unchanged)

Test plan

  • go build ./... succeeds
  • go test -short ./... — all tests pass
  • Version ldflags injection verified: go build -ldflags "-X github.com/timvw/wt/cmd.Version=1.2.3"
  • Binary runs correctly (wt version, wt --help)
  • CI pipeline passes

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.14%. Comparing base (5be4d4e) to head (a5bfe3b).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
cmd/root.go 70.11% 24 Missing and 2 partials ⚠️
cmd/pr.go 0.00% 2 Missing ⚠️
cmd/version.go 0.00% 2 Missing ⚠️
cmd/checkout.go 0.00% 1 Missing ⚠️
cmd/remove.go 0.00% 1 Missing ⚠️
cmd/status.go 92.85% 1 Missing ⚠️
main.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #87      +/-   ##
==========================================
+ Coverage   29.12%   29.14%   +0.01%     
==========================================
  Files          26       27       +1     
  Lines        2712     2714       +2     
==========================================
+ Hits          790      791       +1     
  Misses       1843     1843              
- Partials       79       80       +1     
Files with missing lines Coverage Δ
cmd/cleanup.go 31.09% <ø> (ø)
cmd/config.go 68.06% <ø> (ø)
cmd/config_cmd.go 58.49% <ø> (ø)
cmd/create.go 0.00% <ø> (ø)
cmd/default.go 41.66% <ø> (ø)
cmd/examples.go 67.74% <ø> (ø)
cmd/hooks.go 62.71% <ø> (ø)
cmd/info.go 0.00% <ø> (ø)
cmd/init.go 42.18% <ø> (ø)
cmd/list.go 0.00% <ø> (ø)
... and 16 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Move from flat package main to structured layout:
- cmd/: all cobra commands and CLI logic (package cmd)
- internal/color/: ANSI color utilities
- internal/fuzzy/: fuzzy matching for interactive selectors
- main.go: slim entry point calling cmd.Execute()

Update goreleaser ldflags to use cmd.Version.
@timvw timvw force-pushed the refactor/idiomatic-go-layout branch from 7eda13a to a5bfe3b Compare April 8, 2026 12:50
@timvw timvw enabled auto-merge April 8, 2026 12:50
@timvw timvw merged commit 802916a into main Apr 8, 2026
9 checks passed
@timvw timvw deleted the refactor/idiomatic-go-layout branch April 8, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant