-
Notifications
You must be signed in to change notification settings - Fork 0
FEAT: Add support for additional types #3
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
FEAT: Add support for additional types #3
Conversation
@linkdotnet I have added a POC. Can you please review this whenever you get a change and let me know what you think about it. Thanks 👍 |
Can you also add an entry to the |
Added an entry to the |
LGTM! Is there anything open from your side, or can I merge that into the main branch? |
This can be merged and thanks for the detailed review. |
This code changes comes from the discussion under #1 (comment)
What is changed?
What didn't work
My initial thought process while approaching this change was to leverage generics. But I made a mistake of thinking that generics support in Golang is equivalent to that of other programming languages. With Go's generics support, something such as below is not possible
More details: https://www.reddit.com/r/golang/comments/tvfbow/the_fact_that_methods_are_not_allowed_to_have/
Ok. So let's try another approach. Let's just create multiple
Append
methods with different types. Good old method overloading. Ehhh. Golang does not even supports that in a clean manner. More details: https://stackoverflow.com/a/6987002/3938227What worked
Adding separate methods for each type does the job. Though it is not a clean abstraction as that of other programming languages such as Java(https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html), it gets the job done.
NOTE
This is more of a POC. If this looks good, I can extend this PR to support the remaining types as described under the above API spec of Java's StringBuilder implementation