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