The use of channel in actual combat

In the past, when learning channels, I learned some basic grammar, rules and precautions, but if any knowledge is just to forcefully teach you how to use it without knowing when and where to use it, it will definitely not work. When I was looking at the source code of a project today, I found that Le channel is used in this project to receive signal interruptions and errors!

 Let’s look at this code first. This code first defines an interrupt signal. The three cases are used to receive signals and errors respectively. The first signal.Notify is a built-in function.

The second and third ones return a <- type channel

 At present, I am not very familiar with channel and Ctrip application scenarios. I hope that I will write a detailed article from syntax to specific application scenarios if I gain a deeper understanding in the future!

Guess you like

Origin blog.csdn.net/qq_55621259/article/details/128427652