pilebones / go-udev

Simple udev implementation in Golang
GNU General Public License v3.0
95 stars 28 forks source link

more go-like (IMO) API #33

Closed shigmas closed 7 months ago

shigmas commented 1 year ago

In my experience, most API's can take a 'done' channel, usually like context.Context's, to stop it. And, in general, creators of resources (channels, in this case), should also release that resource. This is closely tied to the done channel.

So, instead of the function creating a done channel, which is closed by the caller, the caller passes in the done channel, and closes it when it wants the function to stop. This removes the secondary purpose of the queue channel also being kind of a close purpose in addition to sending data. This also flows with creators of a channel being the writers to it. (I did keep errors the same, though.)

main.go: