New answers tagged

2

Your Code seems good.The error channel is a good idea. Personally, the only change I would suggest is to use the Generator Pattern (something like this https://medium.com/@thejasbabu/concurrency-patterns-golang-5c5e1bcd0833) in the function "parseJSON" it will split the function into 2 and improve readability.


0

First thing I found weird was the use of globals for the channels. This is generally a bad idea and rarely necessary. Then, in main() there is this dummy channel. It seems to be used as synchronization mechanism without any actual info transported through it. However, it's unclear what the intention is. As it stands, you only make sure that the goroutines ...


1

So currently the WaitGroup is not being used to wait for the producing to complete. This means that it is possible for this programme to run without producing any results as each go produce() is done in it's own go routine so true can be sent immediately to dummy if the main go routine gets all the CPU time thus main exits with nothing being printed. ...


2

Personally I would define it in each package that uses it. It would only be a small amount of duplication but has many advantages: It keeps the package self contained. You mentioned that not all packages use the same method so it stops the interface getting very large. If not every package uses each method it makes it explicit which method a package does ...


0

because OP code is using poor abstractions, the code review that should be produced involves writing a whole new solution from scratch to demonsrate what should have been done going down the path chosen by OP. it is a lot of work, with chances that the end code does not even demonstrate specific solution to some specific flaws of OP code, because the new ...


Top 50 recent answers are included