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

go2avro: cannot use struct composition (kind of inheritance) #90

Closed
sneko opened this issue Jul 31, 2020 · 3 comments
Closed

go2avro: cannot use struct composition (kind of inheritance) #90

sneko opened this issue Jul 31, 2020 · 3 comments

Comments

@sneko
Copy link

sneko commented Jul 31, 2020

Hi,

I'm successfully generating Avro files from Go structure except for one kind of composed structure:

package event

type BaseEvent struct {
	EventID string `json:"eventId"`
}

type Person struct {
	BaseEvent
	Firstname string `json:"firstname"`
}

In my case the Person Avro cannot be generated I get this error:

go2avro: cannot get Avro type: cannot get type: anonymous fields not yet supported (in event.Person)

Reference:

avro/gotype.go

Lines 217 to 219 in 6d3ee10

if f.Anonymous {
return nil, fmt.Errorf("anonymous fields not yet supported (in %s)", t)
}

@rogpeppe I'm not sure but for me that's not an anonymous structure since we know the structure underlying. It's just a merge of properties that needs to be done.

What do you think?

Thank you,

@rogpeppe
Copy link
Contributor

rogpeppe commented Aug 1, 2020

Thanks for the bug report.

I'm sorry, I've used the wrong terminology in the error message there. The error message should say "embedded fields not yet supported". It shouldn't be too hard to support them, but they weren't an initial priority. This is issue #40.

I think this issue should be closed in favour of #40 - @sixstone-qq could you do that please?

@sneko
Copy link
Author

sneko commented Aug 1, 2020

Thank you for the answer @rogpeppe , do you have some advices to try implementing it? I'm not very familiar with Reflect manipulation but I can take a few hours to look at it.

Or do you know a similar "converter" library that already implemented this kind of thing?

@sneko
Copy link
Author

sneko commented Aug 1, 2020

@rogpeppe I worked on it and it seems I have something that works in complex situation.

Will make a PR in a few linked to your issue.

@sneko sneko closed this as completed Aug 1, 2020
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

No branches or pull requests

2 participants