<p>This is probably not a Go specific question, but currently I am trying to display the progress for each goroutine worker in the frontend. The individual task is mainly calling external APIs and process those data into a database.</p>
<p>What would be the general approach to implement such feature?</p>
<hr/>**评论:**<br/><br/>echophant: <pre><p>At a high level, I would pass a status channel into the goroutine, and send an update from the worker on that channel when you have a meaningful update to report. Listen for those status channel updates and aggregate them as necessary, then display that in the frontend.</p></pre>tmornini: <pre><p>An alternative to <a href="/u/echophant" rel="nofollow">/u/echophant</a> is to have a function that creates a progress channel, spawns the worker goroutine, and returns the progress channel to the caller which can then monitor the channel for status updates.</p></pre>thucle: <pre><p>Hi @Nzzy, the idea you can use the channel you keep the status of goroutine. You can check at <a href="https://play.golang.org/p/yHkjO9lFbE" rel="nofollow">https://play.golang.org/p/yHkjO9lFbE</a> . </p>
<p>You can use many channels for many goroutines or one channel for many goroutines with data format to recognize the goroutine's identify.</p></pre>
