Syntax

Go Use a Channel Syntax

In Go, use a channel: sends and receives between goroutines — ch := make(chan int) ch <- 1 v := <-ch

Quick Answer

Syntax
ch := make(chan int) ch <- 1 v := <-ch
GoSyntax

Use a Channel

Code example
ch := make(chan int) ch <- 1 v := <-ch

Sends and receives between goroutines.

Learn More

How to use a channel in Go

  1. Open your Go file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Go Use a Channel Syntax

Use ch := make(chan int) ch <- 1 v := <-ch.

Related Syntax References

Frequently asked questions

What is the Go syntax for use a channel?

Use this pattern: ch := make(chan int) ch <- 1 v := <-ch

Can I copy this Go code example?

Yes. Use Copy code and adapt the example to your program.

Is this Go syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify