The understanding of Chan in Go _go

Source: Internet
Author: User
The classification of Chan

Divided into 2 categories with cache and no caching, especially the use of caching, to prevent the pit from falling.

With no cache
Make (Chan data type)

With cache
Make (Chan data type, length)

For example, define a chan:ch with caching: = Make (chan int,2)
Here we define a 2-cache-Length Chan, when we have written 2 data to Chan, blocking is sent when the third data is written again, until others read the data from the Chan, so that the data can be written again, and the cached Chan resembles a queue, The data cannot be written when the queue is full.
3. Chan's closure
Chan can close with close, and the closed Chan is unable to write data, but can read data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.