Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I haven't looked into Go's actual implementation but isn't this kind of downcasted better suited for interfaces. Your code, as is, wouldn't translate to something like Rust which uses monomorphization; you are doing a runtime "inspection" of the types. This looks more in the domain of duck-typing than something that generics handles.


Here's a writeup exploring this very topic, and showing how Go's generics will currently give worse performance than just using an interface.

https://planetscale.com/blog/generics-can-make-your-go-code-...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: