You're managing a large warehouse. Various suppliers ship different items to your warehouse, and your job is to keep track of the number of products you have. To smoothen this process, you've decided to use a Go program.
Your job is to add each new product concurrently and print the result; to do this, you need to write the necessary code within the following methods:
Within the HandleNewProduct() function, you need to do the following:
Ensure the function notifies the wait group when it finishes its tasks.
Read from the input channel and parse the received product text as long as the channel remains open.
Within the ParseProductText() function, you need to do the following:
Parse the input string (e.g. "apple 5") into a product name and amount. If there's an issue (for instance, if you're unable to parse an amount), simply return an error.
Within the main() function:
Start the
HandleNewProduct()function concurrently using thesync.WaitGroup.Ensure every goroutine finishes before you close the sending channel. This channel is where you transmit your input.