Boldly Go
Blog YouTube Hire Me Contact Daily Email
Boldly Go
Blog YouTube Hire Me Contact Daily Email
Iterators

3 min read


Iterating over channels

For this discussion of iterators, let’s establish a baseline example. It’s made up, but realistic and common: A database method that returns all user orders. We’ll be experimenting with different function signatures, but in general, this is what we can imagine it will look like: func (DB) Orders(ctx context.Context, userID string) ([]*Order, error) And we would consume it with code something like this: orders, err := db.Orders(ctx, userID) if err !

Iterators

2 min read


Iterator patterns

I’m going to change gears from the previous discussion about goroutines, to different ways of iterating. This can closely relate to goroutines, so we’ll bounce back and forth a bit, I suspect. Meanwhile, if you have any questions specifically about goroutines that I didn’t cover, send me an email. I’ll be happy to fill in those gaps! First off, before really diving into iterator patterns, let’s talk about why we might want iterators.

My Content

  • Boldly Go: Daily
  • YouTube

My Services

  • Dev Subscription
  • Private Mentoring

About me

  • Contact Me
  • Privacy Policy

Subscribe to Boldly Go: Daily

Daily suggestions to improve your control of the Go language. I will respect your inbox, and honor my privacy policy.

Not convinced? Browse the archive.

© 2025 Jonathan Hall. All rights reserved.