优化结构

This commit is contained in:
Yvan
2026-08-27 16:20:37 +08:00
parent 001e39da50
commit 653414a1da
54 changed files with 1257 additions and 3450 deletions
+10 -39
View File
@@ -1,41 +1,12 @@
package config
// Clone returns a deep copy of a configuration snapshot. The copy helpers are
// intentionally kept in the config package so data/integration code does not
// need protobuf cloning or storage-specific serializers.
func Clone(value *Config) *Config { return cloneConfig(value) }
func CloneData(value *Data) *Data {
if value == nil {
return nil
}
return cloneConfig(&Config{Data: value}).Data
}
func CloneAdmin(value *Admin) *Admin {
if value == nil {
return nil
}
return cloneConfig(&Config{Admin: value}).Admin
}
func CloneDatabase(value *Database) *Database {
if value == nil {
return nil
}
return cloneConfig(&Config{Data: &Data{Database: value}}).Data.Database
}
func CloneStorage(value *Storage) *Storage {
if value == nil {
return nil
}
return cloneConfig(&Config{Admin: &Admin{Storage: value}}).Admin.Storage
}
func CloneEmail(value *Email) *Email {
if value == nil {
return nil
}
return cloneConfig(&Config{Admin: &Admin{Email: value}}).Admin.Email
}
// The exported clone surface. Deep copying lives in the config package so
// data/integration code needs neither protobuf cloning nor a storage-specific
// serializer to hand out a snapshot a caller may safely mutate. Each function
// returns nil for a nil input.
func Clone(value *Config) *Config { return cloneConfig(value) }
func CloneData(value *Data) *Data { return cloneData(value) }
func CloneAdmin(value *Admin) *Admin { return cloneAdmin(value) }
func CloneDatabase(value *Database) *Database { return clonePtr(value) }
func CloneStorage(value *Storage) *Storage { return cloneStorage(value) }
func CloneEmail(value *Email) *Email { return clonePtr(value) }