Skip to content

refactor: replace go-linq with stdlib slices package#19

Merged
AWaterColorPen merged 1 commit intomainfrom
feature/slices-maps-stdlib-refactor
Apr 12, 2026
Merged

refactor: replace go-linq with stdlib slices package#19
AWaterColorPen merged 1 commit intomainfrom
feature/slices-maps-stdlib-refactor

Conversation

@AWaterColorPen
Copy link
Copy Markdown
Owner

变更说明

使用 Go 1.21+ 标准库 slices 包替换第三方 go-linq 依赖,完成 Phase 1 语法现代化的最后一步。

改动内容

  • api/models/schema.goGetGetDependencyKeylinq.From().Distinct()slices.Sort + slices.Compact
  • dictionary_column.go
    • GetAsTableslinq.From().Distinct()slices.Sort + slices.Compact
    • isSameColumnTablessort.Stringsslices.Sort
  • dictionary_splitter.gopolish 方法中 linq.From().Distinct()slices.Sort + slices.Compact
  • go.mod:移除 github.com/ahmetb/go-linq/v3 依赖

为什么这样改?

go-linq 是一个基于反射的泛型模拟库,在 Go 泛型正式落地后已无必要。slices.Sort + slices.Compact 组合提供了完全等价的去重功能,且:

  • ✅ 类型安全,无反射开销
  • ✅ 标准库,无外部依赖
  • ✅ 代码更清晰易读

测试

所有现有测试通过:go test ./...

- Replace linq.From().Distinct() with slices.Sort + slices.Compact in:
  - api/models/schema.go (GetGetDependencyKey)
  - dictionary_column.go (GetAsTables, isSameColumnTables)
  - dictionary_splitter.go (polish)
- Replace sort.Strings with slices.Sort in dictionary_column.go
- Remove github.com/ahmetb/go-linq/v3 dependency from go.mod

Go 1.21+ stdlib slices package provides equivalent functionality
with better type safety and no external dependency.
@AWaterColorPen AWaterColorPen merged commit 4e43ffa into main Apr 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant