Goroutines and Channels
Part of the Go course
Your program needs to download twenty files. Written the ordinary way, it downloads the first one, waits, downloads the second one, waits, and so on. Almost all of that time is spent doing nothing at all, just waiting for a network that is slower than your processor by a factor of millions. The work would finish twenty times sooner if the waiting overlapped.
Doing several things at once is the oldest hard problem in programming, and most languages make it genuinely difficult. Go was designed around it, and this is the lesson where that shows. You get two ideas. A goroutine is a piece of your program that runs alongside the rest of it. A channel is a pipe for handing values from one goroutine to another, safely, without you having to arrange any locking. ...
Want to learn Go Goroutines and Channels in a real environment?
Click below, get a fresh Linux box with Go ready to go, and work through Goroutines and Channels hands-on with an AI tutor that knows your code.
Start this lessonGoroutines and ChannelsWhat you'll learn
- The go keyword
- Goroutine lifetime
- Unbuffered channels
- Buffered channels
- Send and receive
- Range over channel
- Close a channel
Read this lesson in your language
All lessons in this course
20 lessons- 1Hello, Go25 min
- 2Variables and Types25 min
- 3Control Flow: if and for30 min
- 4Functions30 min
- 5Slices and Maps35 min
- 6Structs and Pointers35 min
- 7Methods and Interfaces35 min
- 8Error Handling35 min
- 9Modules and Project Structure35 min
- 10Tiny CLI Capstone40 min
- 11A Tour of the Standard Library40 min
- 12Testing and Benchmarks40 min
- 13Goroutines and Channels40 min
- 14Concurrency Patterns45 min
- 15Generics35 min
- 16HTTP Servers45 min
- 17Databases with database/sql45 min
- 18Performance and Profiling40 min
- 19Design Patterns in Go40 min
- 20Deployment and Production45 min
