This one-day take-home test is designed to assess your practical understanding of pipeline operations in Go. You'll be implementing a simple data processing pipeline that demonstrates your ability to work with goroutines and channels.
Create a Go program that processes a stream of integers using a pipeline approach. The program should consist of the following stages:
-
Generator: Create a function that generates a stream of random integers (between 1 and 100) and sends them to a channel.
-
Square: Implement a stage that receives numbers from the generator, squares them, and sends the results to the next stage.
-
Sum: Implement a final stage that sums all the numbers it receives and prints the final result.
- Use goroutines to run each stage of the pipeline concurrently.
- The generator should produce 10,000 numbers and above.
- Use buffered channels where appropriate.
- Include comments explaining your code and design decisions.
- Write at least one unit test for each stage of the pipeline.
- Implement proper error handling and graceful shutdown of the pipeline.
- Add a simple command-line flag to control the number of numbers generated.
- Print out how long the entire pipeline takes to process all numbers.
- Create a GitHub repository for your solution.
- Include a
main.go
file with your pipeline implementation. - Write unit tests in a
main_test.go
file. - Update this README with instructions on how to run your program and tests.
Your solution will be evaluated based on:
- Correctness of the pipeline implementation
- Proper use of Go concurrency primitives (goroutines, channels)
- Code organization and clarity
- Error handling
- Quality of unit tests
This test is designed to be completed within one day (about 4-6 hours of focused work). Please submit your solution within 24/48 hours of receiving the test.
Good luck! We look forward to reviewing your solution.