Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does `(<-chan Delivery)(deliveries)` do?

Tags:

go

I found this line:

return (<-chan Delivery)(deliveries), nil

https://github.com/streadway/amqp/blob/master/channel.go#L1089

What does it do? Why the double parentheses?

like image 979
Sławosz Avatar asked Jan 21 '15 12:01

Sławosz


2 Answers

It's a type conversion. In your case, it converts chan Delivery (two-way channel of Delivery values) to <-chan Delivery (receive-only channel of Delivery values).

like image 160
Ainar-G Avatar answered Nov 15 '22 17:11

Ainar-G


It is a type conversion. Returns deliveries as a read-only channel.

like image 27
Toni Cárdenas Avatar answered Nov 15 '22 16:11

Toni Cárdenas