I'm very much used to JavaScript, so, sorry that this might be biased to JS context.
In JavaScript, for asynchronous calls, we use Promises and Streams. Promises are asynchronous singular primitives analogous to values. Streams are asynchronous plural primitives analogous to a list of values.
I'm looking to use something like this in Go. Specifically, lazy loading/transforming/calculating some sequence of data.
So with streams in JS, we have an interface close to Unix pipes. So basically, we can do,
```js
SomeReader().pipe(parseJSON()).pipe(getValue('key')).pipe(makeRequest()).pipe(parseResponse()).pipe(process.stdout);
// similar to
// $ readFile | parseJson | getValue key | makeRequest | parseResponse > stdout
```
In Go, I find it difficult to do something like this. I've seen the "io" package that it supports Reader and Writer interface where you can send a buffer and Pipe it. But applying transformations for the values along the way and similar others aren't clear to me. And I ended up using a straight synchronous flow and spawn go routines whenever something can be done concurrently, and wait for them to complete and continue the flow.
One main issue I have is that there are too many `if err != nil { return "", err }`. Where in JS, I define only one error handler in a chain of events. And if one of them breaks it is caught in this handler, and I handle the error here.
```js
somePromise.then(a).then(b).then(c).catch(handleError);
```
I'm not comparing both the languages putting one over another . I just want to learn (from what I've been using already) - the Go way of doing things.