go-clamd
go-clamd copied to clipboard
Goroutine leak
The anonymous goroutine introduced in https://github.com/dutchcoders/go-clamd/pull/4/commits/4ca7e7b82651009473ab23a8a24bf7f5700f61bd will never exit unless the command is aborted. This leaks a goroutine per successful invocation of ScanStream.
Good catch! I just looked at the code in which I used this library and I think I simply always called close on the abort channel.
Clearly this was way before context.Context became more commonly used, so my suggestion would be to rewrite it a little to use a context instead.
For what it's worth, I did use it in production extensively. So it is possible to use without goroutine leaks.