Guided Walkthrough Labs
Interactive Go Coding Labs
Write Go code in the browser, then reveal the preset test output for each challenge. Nothing here is compiled or executed — the trace is a reference walkthrough.
Walkthroughs viewed: 0 / 3 Labs
ConcurrencyIntermediate
Lab 1: Build a Concurrent Worker Pool
Implement `RunWorkerPool(jobs []int, numWorkers int) []int` that uses a bounded number of worker goroutines and channels to square each number concurrently and return the results.
Verification Test Cases:
Test 1: Square [1, 2, 3, 4, 5] with 3 workers
Input: jobs: [1, 2, 3, 4, 5], workers: 3
Expected: [1, 4, 9, 16, 25]
Test 2: Empty slice [] with 2 workers
Input: jobs: [], workers: 2
Expected: []
Test 3: Single element [10] with 1 worker
Input: jobs: [10], workers: 1
Expected: [100]
solution.go
Preset Test Output (no compiler)
Preset Test Console (recorded go test trace)
Click “Show Preset Test Output” to display the recorded trace for this challenge.