feat: add go struct inventory rust-script #7

Merged
arnold.cui merged 1 commits from feat/go-struct-inventory into main 2026-11-06 17:49:44 +00:00
Member

背景

函数清单(PR #4)之外,struct 是迁移计量的另一半:类型数量决定数据结构层的移植面。

变更内容

  • 新增 scripts/go-struct-inventory.rs(rust-script 单文件,std-only,无注释)
  • 输出 CSV 三列:name / module(文件名去后缀)/ path(相对扫描根目录),按模块、名称排序
  • 六态词法状态机:代码 / 行注释 / 块注释 / 解释字符串 / 原始字符串 / rune 字面量;只认顶格声明
  • 支持 type ( 分组声明、嵌套泛型参数、struct 别名(type X = struct{...})
  • 输出默认落 csv-records/go-struct-inventory.csv,支持 [目标目录] [输出文件] 参数

自测结果

  • 全量跑 ~/workspace/TypeScript:5219 个文件,2378 个 struct
  • 与 go/parser 构造性真值(30 行 Go 程序,go/ast 遍历顶层 TypeSpec)逐行 diff 完全一致
  • 开发过程中通过该真值抓出并修复三处解析缺陷:分组内非 struct 条目导致状态逃逸、struct 别名形态(type X = struct{})、迭代器类型错误
  • csv-records/ 被 .gitignore 忽略,数据不入库
## 背景 函数清单(PR #4)之外,struct 是迁移计量的另一半:类型数量决定数据结构层的移植面。 ## 变更内容 - 新增 scripts/go-struct-inventory.rs(rust-script 单文件,std-only,无注释) - 输出 CSV 三列:name / module(文件名去后缀)/ path(相对扫描根目录),按模块、名称排序 - 六态词法状态机:代码 / 行注释 / 块注释 / 解释字符串 / 原始字符串 / rune 字面量;只认顶格声明 - 支持 type ( 分组声明、嵌套泛型参数、struct 别名(type X = struct{...}) - 输出默认落 csv-records/go-struct-inventory.csv,支持 [目标目录] [输出文件] 参数 ## 自测结果 - 全量跑 ~/workspace/TypeScript:5219 个文件,2378 个 struct - 与 go/parser 构造性真值(30 行 Go 程序,go/ast 遍历顶层 TypeSpec)逐行 diff 完全一致 - 开发过程中通过该真值抓出并修复三处解析缺陷:分组内非 struct 条目导致状态逃逸、struct 别名形态(type X = struct{})、迭代器类型错误 - csv-records/ 被 .gitignore 忽略,数据不入库
arnold.cui-agent added 1 commit 2026-11-06 14:02:01 +00:00
新增 scripts/go-struct-inventory.rs:扫描 Go 顶层 struct 声明,
输出 CSV(name/module/path),按模块与名称排序,与 func 清单
同构。带六态词法状态机(代码/行注释/块注释/解释字符串/原始
字符串/rune 字面量),正确处理 type ( 分组声明、嵌套泛型参数
与 struct 别名(type X = struct{...});输出默认落
csv-records/。
arnold.cui approved these changes 2026-11-06 17:49:38 +00:00
arnold.cui merged commit d1fef8c147 into main 2026-11-06 17:49:44 +00:00
arnold.cui deleted branch feat/go-struct-inventory 2026-11-06 17:49:44 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: idealjs/tsox#7