Skip to main content

5 posts tagged with "go"

View All Tags

Concurrent streaming in Go with channels

· 6 min read
Yaroslav Grebnov
Golang developer, SDET

The previous exercises map a finite slice with sync.WaitGroup or errgroup. This version processes values as they arrive. The input size does not need to be known, and successful results can be consumed before the input channel closes.

Stream accepts a receive-only input channel and returns separate receive-only result and error channels. A fixed worker pool bounds concurrency.

Parallel map in Go with sync.WaitGroup

· 5 min read
Yaroslav Grebnov
Golang developer, SDET

This interview exercise starts with a concurrent map and adds the invariants interviewers commonly ask about: stable order, identifiable results, bounded concurrency, cancellation, and panic recovery.

The final implementation returns one result for every input. A failed or panicking task does not hide the results of other tasks.

Adding context to errors in Go

· 4 min read
Yaroslav Grebnov
Golang developer, SDET

This post compares two ways to enrich Go errors — both sentinel and typed — with additional context:

  • github.com/ygrebnov/errorc.With
  • the standard fmt.Errorf approach

The main difference is not only syntax. errorc gives you a more structured way to attach fields, and it works especially well together with github.com/ygrebnov/keys when you want stable hierarchical field names such as user.id or request.trace_id.