Creators to follow

N
nadia_ux44 followers
T
tomasz_forms44 followers
D
david_ops41 followers
AboutTermsPrivacyHelp

© 2026 teliprompt

AH
ahmed_go
3 months ago•
Coding

Go concurrent worker pool with error propagation

GPT-5
code output
#golang
#concurrency
#worker-pool
#errgroup
#context
Views
4.2K
Copies
718
Likes
802
Comments
0
Copy rate
17.0%

Prompt

Act as a senior Go engineer. Write an idiomatic concurrent worker pool in Go.

Requirements:
- Pool size: [worker_count] workers
- Job type: [job_type]
- Use `context.Context` for cancellation — first error cancels all workers
- Use `errgroup.Group` from `golang.org/x/sync/errgroup`
- Bounded channel of jobs, workers read until channel closes
- Results streamed on an output channel preserving job->result association
- Graceful shutdown on SIGINT / SIGTERM
- Fail-fast option controlled by a `FailFast bool` field
- Clean shutdown: all goroutines must exit, no leaks
- Public API: `Pool.Run(ctx, jobs []Job) ([]Result, error)`
- Include a `main()` demo that submits 20 jobs, one of which errors, and prints the outcome

Output format:
- A single `main.go` file, complete and runnable
- Use idiomatic Go: lowercase package `main`, clear names, no global state
- No external deps beyond `golang.org/x/sync/errgroup`
- Add concise doc comments on exported identifiers

Customise this prompt

Fill in 2 variables to personalise this prompt

Preview
Act as a senior Go engineer. Write an idiomatic concurrent worker pool in Go. Requirements: - Pool size: [worker_count] workers - Job type: [job_type] - Use `context.Context` for cancellation — first error cancels all workers - Use `errgroup.Group` from `golang.org/x/sync/errgroup` - Bounded channel of jobs, workers read until channel closes - Results streamed on an output channel preserving job->result association - Graceful shutdown on SIGINT / SIGTERM - Fail-fast option controlled by a `FailFast bool` field - Clean shutdown: all goroutines must exit, no leaks - Public API: `Pool.Run(ctx, jobs []Job) ([]Result, error)` - Include a `main()` demo that submits 20 jobs, one of which errors, and prints the outcome Output format: - A single `main.go` file, complete and runnable - Use idiomatic Go: lowercase package `main`, clear names, no global state - No external deps beyond `golang.org/x/sync/errgroup` - Add concise doc comments on exported identifiers

Example output

Related prompts

Async iterators and generators in modern JavaScript: a working guideby @olivia_test
Coding
TypeScript type narrowing cheat sheet with runnable examplesby @marcus_react
Coding
CLI tool builder with argument parsing and colored outputby @nikolai_rust
Coding
Convert JavaScript to strict TypeScript with full type safetyby @marcus_react
Coding