← All Exercises
Go Goroutine Basics
intermediatego
Background
Goroutines are lightweight threads managed by the Go runtime, enabling efficient concurrent programming.
Problem
Write a Go function that launches N goroutines to compute squares of numbers concurrently and collects results safely.
Input
A slice of integers to square concurrently.
Output
A slice of squared values in the same order.
Sample tests
Sample 1
Input: [1, 2, 3, 4, 5]
Expected: [1, 4, 9, 16, 25]
Your solution
Learning objective
Learn goroutine launching, WaitGroup synchronization, and safe concurrent slice writing.