[go-fan] Go Module Review: github.com/charmbracelet/x/exp/golden
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
改动位于 pkg/console/golden_test.go 的第 340、345、350 和 355 行,其中 []byte(bar.Update(...)) 被传给了 golden.RequireEqual。将其与附近已直接传递字符串的调用进行比较,然后删除这四处类型转换。运行 go test ./pkg/console/... 以确认 golden 固定数据仍然匹配。完成标准是类型转换已删除,且测试在不重新生成任何固定数据的情况下通过。
由索引模型根据 Issue 内容生成。
描述
🐹 Go Fan Report: github.com/charmbracelet/x/exp/golden
Module Overview
golden is a tiny (~90 LOC) golden-file testing helper from the charmbracelet/x monorepo. It exposes one generic function, RequireEqual[T []byte | string](tb, out), that diffs test output against a testdata/<TestName>.golden fixture (escaping control/ANSI sequences before comparing), and can regenerate fixtures when run with -update.
Current Usage in gh-aw
- Files: 2 (
pkg/console/golden_test.go,pkg/workflow/wasm_golden_test.go) - Import Count: 2
- Call sites: 14 total (11 + 3)
- Key APIs Used:
golden.RequireEqualonly (current, non-deprecated API) - Golden regeneration is already wired into
make update-goldenandmake update-wasm-golden, both passing-update- exactly the workflow the module documents.
Research Findings
exp/golden/v0.1.0 (pinned in go.mod) is the only tag ever cut for this submodule and remains the latest release, even though the parent charmbracelet/x monorepo is very active (most recent push 2026-10-12, on an unrelated submodule). Nothing to upgrade to.
Recent Updates
All already baked into the pinned v0.1.0 tag:
- feat(exp/golden): accept strings on RequireEqual (2025-06-02) - added generics so callers no longer need to wrap string output in []byte(...).
- RequireEqualEscape was deprecated in favor of RequireEqual (escaping is now always on by default).
- No security advisories or breaking changes found.
Best Practices
Maintainers recommend calling RequireEqual directly with either string or []byte output (no manual conversion needed since generics landed), and exposing a -update test flag/make target for fixture regeneration.
Improvement Opportunities
🏃 Quick Wins
pkg/console/golden_test.go:340,345,350,355 still wrap ProgressBar.Update(...) (which returns string) in an unnecessary []byte(...) conversion before calling golden.RequireEqual. Every other call site in the same file (RenderTable, FormatError, RenderInfoSection, etc.) already passes the string directly. Dropping these 4 remaining casts removes a small unneeded allocation per call and makes the file internally consistent:
Affected lines
// pkg/console/golden_test.go
340: golden.RequireEqual(t, []byte(bar.Update(0)))
345: golden.RequireEqual(t, []byte(bar.Update(512*1024*1024)))
350: golden.RequireEqual(t, []byte(bar.Update(1024)))
355: golden.RequireEqual(t, []byte(bar.Update(0)))
Change each to golden.RequireEqual(t, bar.Update(...)).
✨ Feature Opportunities
None currently applicable - the only tagged release (v0.1.0) already contains every feature gh-aw relies on (string support, escaping, Windows CRLF normalization), and there is no newer upstream tag to adopt.
📏 Best Practice Alignment
- Golden regeneration already follows the documented -update flag pattern via dedicated make targets.
- No usage of the deprecated RequireEqualEscape was found anywhere in the codebase.
🔧 General Improvements
pkg/workflow/wasm_golden_test.go runs its own normalizeOutput helper (stripping env-specific flags, trimming trailing newlines) before calling RequireEqual. This is project-specific normalization and does not overlap with what the library provides (control-sequence escaping, CRLF normalization) - no redundancy to clean up.
Recommendations
- Apply the quick win above (drop the 4 redundant []byte(...) casts in pkg/console/golden_test.go) - small, safe, mechanical cleanup.
- No version bump or feature adoption needed; the module is already on its latest (and only) release and is used idiomatically elsewhere in the codebase.
Next Steps
No further action needed beyond the quick win above; re-review this module once charmbracelet/x/exp/golden cuts a new tag (none exists yet beyond v0.1.0).
Generated by Go Fan
Module summary saved to: scratchpad/mods/charmbracelet-x-exp-golden.md
Generated by 🐹 Go Fan · claude · agent · 126.8 AIC · ⊞ 6.5K · ◷
- expires on Oct 16, 2026, 12:05 AM UTC-08:00
- 主要语言
- Go
- 星标
- 5.4k
- 派生
- 584
- 平均合并
- 3 小时 38 分钟
- 30 天内合并 PR
- 826
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/gh-aw 的其他 Issue
-
ai-inspected
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
automated conformance safe-outputs
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
goroutineresourceleak (81st linter): paren_unwrap_gap across lock/cancel/channel detection, day one未关闭cookie sergo
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
agentic-workflows cascade-suspected
难度 4/5 3-5 天 新手友好度 22/100
维护者通常 1 天内回复
-
agentic-workflows cascade-suspected
难度 4/5 1-2 天 新手友好度 15/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
documentation hacktoberfest priority: low skill: good first issue status: ready for dev
难度 2/5 半天 新手友好度 85/100
hyperledger-labs/fabric-smart-client#2142 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
numberly/vault-db-injector#107 ·
维护者通常 1 天内回复
-
area/import kind/bug
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
[DOC] Wrong sg_egress_ports range in the Terraform Databricks Guide for AWS Hub & Spoke with Network Firewall可能已有人在做 @akhil9tiet 今天认领。 未关闭docs
难度 1/5 1 小时以内 新手友好度 72/100
databricks/terraform-provider-databricks#6080 · 1 条评论 ·
维护者通常 3 天内回复