3 ms·
>I can’t say I love the way Go implemented it though. Why not?
by fuzztester 2y ago
>I can’t say I love the way Go implemented it though.
Why not?
- hnlmorg 2y agoIt might just be user error on my part but it wasn’t entirely clear to me: 1. How it should be implemented “correctly” 2. The resulting code isn’t clear how it works at first glance (particularly with the yield command, it has “magical” properties that take a little effort to grok) 3. Requires calling a method Example code: https://github.com/lmorg/Ttyphoon/blob/321738f289e4791e9674d05c28e359b23fe96e5a/tmux/pane_map.go#L41 https://github.com/lmorg/Ttyphoon/blob/321738f289e4791e9674d... I did write this at something like 11pm so it’s entirely possible I’ve done this completely wrong though. Also please ignore the weird use of mutexes here too. I’m also aware that sync.Map could/should have been used here. This struct was more of an experiment than anything that will ultimately find its way into production code.
- dharmab 2y agoIn this specific case, one could do something like https://github.com/dharmab/skyeye/blob/main/pkg/radar/contacts.go#L114 https://github.com/dharmab/skyeye/blob/main/pkg/radar/contac.... But your critique is still relevant for cases where you are generating/querying items on demand.
- hnlmorg 2y agoThanks for sharing that. I’ll give that a play tonight.