Hacker News new | ask | show | jobs
by drdaeman 3149 days ago
> But if you do a website or webapp, 99% of your code is not using interface{} in it's methods.

How do you deal with the lack of sets and trees? I believe those two data structures are frequently almost indispensable - even in the most boring mostly-CRUD web projects. And it's either type assertions on {}interfaces or go-generate based specialized implementations. Both feel odd to me. (Am I missing something?)

1 comments

For Sets, you can get away with the language slices and maps, which work sufficiently well.

I haven't found a need for trees in most of my projects and where I did I implemented it when necessary.

You can however, if you need to, separate the code and data of a tree by using a data adapter. The tree only stores a unique ID for an object which you can receive using the adapter, which would be a simple map or slice.

But as mentioned, I very very rarely needed them and not yet in any CRUD web project.