preferred-libraries.md

 1# Preferred libraries
 2
 3Prefer the standard library until a library earns its keep. When a library is
 4needed, these are the usual defaults.
 5
 6| Need | Default | Notes |
 7| --- | --- | --- |
 8| TOML config | `github.com/BurntSushi/toml` | Preferred for direct, boring TOML parsing. Avoid heavy config frameworks by default. |
 9| CLI commands | `github.com/spf13/cobra` + `charm.land/fang/v2` | Cobra for command structure; Fang for polished help, errors, version, and signal handling. Tiny tools may use stdlib. |
10| TUI implementation | Charm v2 stack via `golang-tui` | Load `golang-tui` for Bubble Tea, Lip Gloss, Bubbles, testing, layout, keymap, terminal, and performance details. |
11| MCP server | `github.com/modelcontextprotocol/go-sdk` | Use typed parameter structs, tool annotations, stdio by default. |
12| Wails desktop | `github.com/wailsapp/wails/v2` | Go owns domain logic; frontend renders state and calls bindings. |
13| Light web server | `net/http`, `html/template`, `embed` | Default web stack for mostly server-rendered apps. |
14| User-provided HTML sanitisation | `github.com/microcosm-cc/bluemonday` | Use strict or UGC policies intentionally. |
15| SQLite without CGO | `modernc.org/sqlite` through `database/sql` | Useful for easily shipped binaries. Reconsider if CGO is already required. |
16| RSS/Atom | `github.com/mmcdole/gofeed` | Fine for feed ingestion. |
17| Git access in-process | `github.com/go-git/go-git/v5` | Useful when shelling out to git is not acceptable. |
18| Behaviour specs | `github.com/regen-network/gocuke` | Explicit opt-in only. Ask whether the project wants gocuke before adding it. |
19| Property tests | `pgregory.net/rapid` | Add around parsers, state machines, and merge logic. |
20| Comparisons in tests | `github.com/google/go-cmp/cmp` | Prefer over ad-hoc string diffs for structured values. |
21| Linux packages | `nfpm` | Prefer for `.deb`, `.rpm`, `.apk`, and Arch package artifacts. |
22
23## Dependency rules
24
25- Add dependencies with the relevant CLI (`go get`, `go install`, package
26  manager command); do not hand-edit manifests.
27- Keep direct dependencies direct and intentional. Run `go mod tidy` after
28  changes.
29- Prefer concrete types. Avoid broad maps, `any`, or reflection unless parsing a
30  real untyped boundary.
31- If a project already made a different good choice, preserve it unless the user
32  asked for an opinionated migration.