What is the <-
operator in go language? Have seen this in many code snippets related to Go but what is the meaning of it?
You've already got answers, but here goes.
Think of a channel as a message queue.
If the channel is on the right of the left arrow (<-) operator, it means to dequeue an entry. Saving the entry in a variable is optional
e <- q
If the channel is on the left of the left arrow operator, it means to enqueue an entry.
q <- e
Further note about "dequeue" (receive) without storing in a variable: it can be used on a non-buffered queue to implement something like a "wait/notify" operation in Java: One coroutine is blocked waiting to dequeue/receive a signal, then another coroutine enqueues/sends that signal, the content of which is unimportant. (alternately, the sender could be blocked until the receiver pulls out the message)