I was reading some go code and say a few different ways to pass go channels. Maybe they are the same but I was wondering if there is any difference since I couldn't find documentation online:
1)
func serve(ch <-chan interface{}){ //do stuff }
2)
func serve(ch chan<- interface{}){ //do stuff }
3)
func serve(ch chan interface{}){ //do stuff }
4)
func server(ch *chan interface{}){ //do stuff}
I was wondering what the difference between them were and if they were just equivalent ways to do the same thing: pass a channel around different goroutines.
NOTE: I am aware that there is no reason to pass a pointer to a chan, map, or slice, or function value, since those are all reference types which internally contain a pointer (the exception would be if you want the callee to change the reference type header). The only reason I provided it is for completeness (i.e. to really provide every way a channel could be attempted to be passed as a parameter and to make on question that hopefully, references all ways to do this and compares them).