#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Concurrency

Channels in Go – Buffered, Unbuffered, and Select Statement

What is a Channel?

A channel is a typed conduit used to send and receive values between goroutines, enabling safe communication without explicit locks.

Unbuffered Channels

ch := make(chan int)

go func() {
    ch <- 42 // sends value, blocks until received
}()

value := <-ch // receives value
fmt.Println(value)

Buffered Channels

ch := make(chan int, 3) // capacity of 3
ch <- 1
ch <- 2
ch <- 3
// sending a 4th value would block until space is available

The select Statement

select lets a goroutine wait on multiple channel operations, proceeding with whichever is ready first.

select {
case msg1 := <-ch1:
    fmt.Println("Received:", msg1)
case msg2 := <-ch2:
    fmt.Println("Received:", msg2)
default:
    fmt.Println("No message ready")
}

Ready to master real-world Go skills?

Learn Go hands-on with mentor-led, live sessions.

Explore Course