4 ms·
Interesting idea, how do you imagine a channel based API for this?
by asciimoo 9y ago
Interesting idea, how do you imagine a channel based API for this?
- JoeAcchino 9y agoWould this work? c := colly.NewCollector() // this functions create a goroutine and returns a channel ch := c.HTML("a") e := <- ch link := e.Attr("href") // ... I'm a bit rusty (ah!) with go, so bear with me if the above contains errors.
- hellcow 9y agoI would ignore the GP's advice. Channels are prone to big errors -- panics and blocking -- which aren't detectable at compile time. They make sense to use internally but shouldn't be exposed in a public API. As one example, notice how the standard library's net/http package doesn't require you to use channels, but it uses them internally.