Skip to content
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

Merged
merged 1 commit into from
Jul 25, 2024
Merged

ref configs #6

merged 1 commit into from
Jul 25, 2024

Conversation

jice36
Copy link
Contributor

@jice36 jice36 commented Jul 25, 2024

No description provided.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А чего за пределы цикла ValueOf не вынес? Я же об этом еще в прошлом ПРе писал...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я подумал, что дело только в перезатирании, ща перенесу

Copy link
Contributor

@dalogutk dalogutk Jul 25, 2024

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) после всех модификаций, чтобы вернуть финальное значение.

Copy link
Contributor

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 это конфиг пайплайнера.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я создал две структуры с одинаковым полями и закинул их туда, он нужную структуру вернул

@jice36 jice36 force-pushed the feature/sink_kafka_click branch from d407b98 to 9503ce8 Compare July 25, 2024 18:32
@jice36 jice36 merged commit c6a636b into main Jul 25, 2024
0 of 2 checks passed
@jice36 jice36 deleted the feature/sink_kafka_click branch July 25, 2024 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants