On Sun, Nov 06, 2022 at 01:33:59AM +0530, Shubh Karman Singh wrote: > I am refactoring a JS library to Go. I have some questions but I'm not able > to find some concrete answers for this. > 1. What's the idiomatic way to refactor Asynchronous JS APIs to Go? > 2. How to refactor Callbacks from JS to Golang? I have seen some Go code > which takes function as an input parameter. Is the intent same here?
While my exposure to programming is twice as less than that of Kurtis, I would like to support his view on this. The chief idea of Go's concurrency is that it's integrated into the language's code - as opposed to be bolted on in form of a library, as is the case with most other popular programming languages out there. This is one of the reasons why you don't see many callbacks in idomatic Go code: they are either not needed or their functionality is implemented via sending values via channels and a set of patterns involving them (see [1, 2, 3]). For a good and fun overview of that "in core" vs "as a library" distinction please see [4]. 1. https://go.dev/blog/concurrency-timeouts 2. https://go.dev/blog/pipelines 3. https://go.dev/blog/io2013-talk-concurrency 4. https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/20221106104252.mu5ttxabdhthy26d%40carbon.