GoLang language specification Document: What the declaration chan<- <-chan int means

Hi,
I was going through the documentation.

https://golang.org/ref/spec#Channel_types

There is a section as below:

The <- operator associates with the leftmost chan possible:

chan<- chan int // same as chan<- (chan int)
chan<- <-chan int // same as chan<- (<-chan int)
<-chan <-chan int // same as <-chan (<-chan int)
chan (<-chan int)

All above 4 scenarios, I did not understand. Please help me to understand.

What exactly did you not understand?

The examples are pretty clear. They tell you how the <- operator binds to the various chan in the type.

They have an unparenthised type and then an equivalent type written with parenthesis.

The declaration like below is completely understandable
chan

like var1 chan<- float64
it means var1 is a FIFO channel can only be used for sending float64 values.

But the following statement is confusing

var1 chan<- <-chan int

Can you please break it and help me to understand.

I am sorry if my subject line is not humble in nature. I am changing it

That is a channel for sending channels that can receive integer values.

1 Like

Thank you very much for the response.
But I have dissected the syntax and checked it in the playground on my own. I have a clear picture now.

The channel variable declaration has two parts.
channel_variable channel_type

channel_type further can be dissected as below

  1. chan keyword, which depicts the variable as a channel.
  2. Direction of the channel (sending and receiving). (optional)
  3. Type of the value, a channel can hold.

A channel_type syntax can be used as a type of value a channel can hold in another channel declaration. Which is point number 3. in the above description

This is how the language specification should have been mentioned similar for the channel topic.