4 ms·
Isn't interface{} similar to void * - the king of hiding types?
by lttlrck 5y ago
Isn't interface{} similar to void * - the king of hiding types?
- hellcow 5y agoYes, but it's a bit like Rust's `unsafe` in that reaching for it first is not a great practice. There's usually a better way. Using interface{} where you truly don't know and can't predict the data being sent to you is mostly something that libraries (like encoding/json) have already handled, so I don't have to interact with it much directly. I think generics are going to have the biggest impact in adding effortless type safety to all kinds of libraries, though.
- aaomidi 5y agoI really don't come across this in most projects I read and learn from.