channel คือท่อส่งข้อมูลที่มีชนิดสำหรับ การสื่อสารระหว่าง goroutine — goroutine หนึ่งส่งค่า อีก goroutine หนึ่งรับ channel คือวิธีที่ goroutine ของ Go ส่งข้อมูลและ synchronize อย่างปลอดภัย เป็นการสะท้อนคติพจน์ "share memory by communicating"
การสร้างและใช้งาน channel
ch := ( )
{
ch <-
}()
value := <-ch
fmt.Println(value)
