Hands-On Test-Driven Labs

Interactive Go Coding Labs

Write real Go code directly in the browser and pass automated test suites with instant feedback.

Completed: 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
Go 1.24 Test Runner
Test Suite Console (go test)
Click “Run Test Suite” to execute the verification tests against your solution.