Review this generated settings patcher against the task.
Update a non-nil *Settings only through edit tags, reject unknown, nil, or incompatible values without panicking, never expose AdminToken, and reuse validated metadata in batch processing.
Go
package config
import "reflect"
type Settings struct {
Host string `edit:"host"`
Port int `edit:"port"`
AdminToken string
}
func Apply(dst any, changes map[string]any) error {
target := reflect.ValueOf(dst).Elem()
for name, raw := range changes {
field := target.FieldByName(name)
if !field.IsValid() {
continue
}
candidate := reflect.ValueOf(raw)
if candidate.Type().ConvertibleTo(field.Type()) {
field.Set(candidate.Convert(field.Type()))
}
}
return nil
}
generated code is illustrative, not from any one model