refactor: replace go-linq with stdlib slices package#19
Merged
AWaterColorPen merged 1 commit intomainfrom Apr 12, 2026
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更说明
使用 Go 1.21+ 标准库
slices包替换第三方go-linq依赖,完成 Phase 1 语法现代化的最后一步。改动内容
api/models/schema.go:GetGetDependencyKey中linq.From().Distinct()→slices.Sort + slices.Compactdictionary_column.go:GetAsTables中linq.From().Distinct()→slices.Sort + slices.CompactisSameColumnTables中sort.Strings→slices.Sortdictionary_splitter.go:polish方法中linq.From().Distinct()→slices.Sort + slices.Compactgo.mod:移除github.com/ahmetb/go-linq/v3依赖为什么这样改?
go-linq是一个基于反射的泛型模拟库,在 Go 泛型正式落地后已无必要。slices.Sort + slices.Compact组合提供了完全等价的去重功能,且:测试
所有现有测试通过:
go test ./...