Skip to content

[refactor][P3] container.Map 与 SafeMap 的内容出口不对偶——SafeMap.Snapshot 承诺「对偶闭合」,Map 缺同名原语 #393

Closed

Description

@zy84338719

来源:2026-11-11 全矩阵深度代码审查(6 路并行扫描约 24 万行 Go)。判定已复核;行号基于 2026-11-11 的 main,动手前请核对现场。
归档索引:#372(本仓重构 backlog)

位置

pkg/container/map.go(无 Snapshot;仅 Load/Store/LoadOrStore/Delete/Range/Len/Clear)对照 safemap.go:97-105

证据

safemap.go:91-94 明文承诺「API 对偶闭合后,『容器内容出口』两个形态(有序 → []T,键值 → map[K]V)都有单调用原语;调用方不再手写『Range 构建副本』的样板循环」。但同包 sync.Map 背书的 Map 只有 Range(map.go:45),要拿 map[K]V 副本只能手写 Range 循环——正是 Snapshot 注释点名要消灭的样板;webhook.Registry 用的恰是 SafeMap.Snapshot(registry.go:59-67),两个 Map 类型行为面漂移。

建议

Map 补 Snapshot() map[K]V(sync.Map.Range 锁外遍历语义下同样安全,直接收集);两个类型的 godoc 互链,写明出口原语对偶。

Activity

  1. moved this from Todo to In Progress in oekit Issue 大盘on Nov 12, 2026
  2. added a commit that references this issue on Nov 12, 2026
  3. moved this from In Progress to Done in oekit Issue 大盘on Nov 12, 2026
  4. zy84338719 commented on Nov 12, 2026

    @zy84338719
    ContributorAuthor

    已合入修复 ✅(无 SemVer 发布:本次改动不发版本)

    变更内容

    container.Map 补 Snapshot() 与 SafeMap.Snapshot 同名对偶闭合,godoc 互链

    合入:PR #423(https://github.com/oekit/pkg/pull/423),merge commit 53135ccf,2026-11-12T17:13:18Z

    CI:link ✅ / Lint & Test / Test ✅ / Lint & Test / Lint ✅ / Zero Third-Party Deps ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactor重构机会(代码审查产出)

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions