← All Exercises

Go Concurrent Pipeline

advancedgo~35min

Background

Concurrent pipelines leverage Go CSP model for efficient parallel data processing across multiple stages.

Problem

Create a pipeline with three stages: generate numbers, filter primes, and square results, using channels between stages.

Input

A maximum number N to generate and process.

Output

A slice of squared prime numbers up to N.

Sample tests

Sample 1

Input: 10
Expected: [4, 9, 25, 49]

Your solution

Learning objective

Master multi-stage concurrent pipelines, channel chaining, and goroutine lifecycle management.