awalterschulze / goderive

Derives and generates mundane golang functions that you do not want to maintain yourself
Apache License 2.0
1.23k stars 44 forks source link

Allow Recursive Functions to take extra function parameters for private fields #55

Open awalterschulze opened 5 years ago

awalterschulze commented 5 years ago

For example

deriveEqual(T, T, func(A, A) bool, func(B, B) bool) bool

, where T contains a field with type A and B

awalterschulze commented 5 years ago

This also includes:

This can be especially useful for time.Time, which has loads of private fields, but can be easily handled with a special case function.

Tackling a single one of these would be greatly appreciated.

awalterschulze commented 5 years ago

The idea is when you traverse through the struct and find a field that matches the input type of one of the input functions, you should rather use the function provided in the parameter recursing deeper. This almost the same as calling the Equal method rather than generating your own.

awalterschulze commented 5 years ago

This is the generic version of issue https://github.com/awalterschulze/goderive/issues/47

OladapoAjala commented 2 years ago

@awalterschulze is the generic version solved or it is still open?

awalterschulze commented 2 years ago

There is a lot of discussion about how to solve the generic version in https://github.com/awalterschulze/goderive/issues/47 If you are interested, I don't think any work has been done yet

OladapoAjala commented 2 years ago

Nice, I'm interested in tackling the generic version, sounds fun to me!

awalterschulze commented 2 years ago

Go for it, first make sure you understand what has been agreed upon in #47 Do a small prototype, to make sure you don't do too much work before checking that we are on the same page.