refactor: 消除 Config 双重表示 (#4)#10
Merged
Merged
Conversation
added 2 commits
July 10, 2026 20:52
- 定义 KeyMutation 类型(KeyEnable/KeyDisable/KeyRemove) - 提取 updateKey 函数,统一处理加载-验证-修改-保存-重载流程 - 三个命令的 RunE 各精简为 3 行 - 不改变 CLI 接口 Closes #3
- 给 Config 结构体所有字段添加 toml tag - 删除 TomlProviderConfig 结构体 - 删除 tomlToConfig/configToToml 转换函数 - TomlConfig.Provider 类型改为 map[string]*Config - 新增 mergeConfig 函数处理 TOML 解析后的默认值回填 - 更新所有引用点(cmd/config.go, cmd/provider.go, config_loader.go, 测试) - TOML 配置格式不变,向后兼容 Closes #4
bigmanBass666
marked this pull request as ready for review
July 10, 2026 14:37
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.
变更内容
将
internal/config包中的Config和TomlProviderConfig两个结构体合并为一个。纯重构,不改变 TOML 配置格式。具体变更
Config所有字段添加tomltag(保留 Go 字段名和 JSON tag)TomlProviderConfig结构体tomlToConfig和configToToml转换函数(-58 行模板代码)TomlConfig.Provider类型改为map[string]*ConfigmergeConfig函数处理 TOML 解析后的默认值回填cmd/config.go,cmd/provider.go,config_loader.go,config_test.go)文件改动
验收标准
go build ./...通过go test -tags=unit ./...全部通过go vet ./...通过Closes #4