Original link: https://v3u.cn/a_id_241
As we all know, the scope of Golang is relatively strict, and the communication between data often depends on the transmission of parameters. However, if you want to communicate data among multiple coroutine tasks, you need the participation of channels. We can encapsulate the data as An object, and then pass the pointer of this object into a channel variable, and another coroutine reads the pointer of the variable from this channel and processes the memory object it points to. Channel declaration and creation packagemainimport”fmt”funcmain(){varachanintifa==nil{fmt.Println(“The channel is empty and cannot be used, you need to create a channel first”) a=make(chanint)fmt.Printf(“Data type Yes: %T&quo…
This article is reprinted from: https://v3u.cn/a_id_241
This site is for inclusion only, and the copyright belongs to the original author.