Hah, great question!
Channels are more about communication and synchronization than streaming data, tbh. Everything you can do with streams you can also do with channels, but take into account that the result will very probably be much less efficient.
This is due to the inherent complexity on making things work correctly across multiple goroutines and threads.
If you want to write with streams in Go, io.Reader and io.Writer are your friends!
For instance you could do something like:
http.Get on a url that serves a zipped json file, that returns an http.Response
- Create a
zip.Reader reading from http.Response.Body
- create a
json.Decoder reading from zip.Reader
io.Copy from the json.Decoder to os.Stdout
This will start printing the first decoded objects from JSON before you're actually done downloading the file if the network is slow enough!
So if you wanna do data streaming use io.Reader and io.Writer, if you wanna do synchronization of workers sharing tasks channels.
For the synchronization of tasks, check out this talk by John-Graham Cumming!
https://www.youtube.com/watch?v=woCg2zaIVzQ