-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref configs #6
ref configs #6
Conversation
config.go
Outdated
for i := 0; i < val.NumField(); i++ { | ||
fieldName := val.Type().Field(i).Name | ||
|
||
valueField := val.FieldByName(fieldName) | ||
valueField := reflect.ValueOf(config).Elem().FieldByName(fieldName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А чего за пределы цикла ValueOf не вынес? Я же об этом еще в прошлом ПРе писал...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я подумал, что дело только в перезатирании, ща перенесу
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По поводу перезатирания надо потестить, я не уверен что reflect.Value автоматом переписывает оригинальный конфиг V-типа (а просто копирует содержимое во время ValueOf и дальше перезаписывает чисто свою копию). Обычно для такого пишут res.Interface().(V) после всех модификаций, чтобы вернуть финальное значение.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А может и переписывает, там под капотом вот такая фигня происходит e := (*emptyInterface)(unsafe.Pointer(&i))
где i это конфиг пайплайнера.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я создал две структуры с одинаковым полями и закинул их туда, он нужную структуру вернул
d407b98
to
9503ce8
Compare
No description provided.