How to cancel goroutines after certain amount of time
问题 I am making a load testing tool that makes multiple HTTP calls in goroutines, and it works, but now I am trying to allow it to run for only a specified duration. How can I cancel the goroutines when the sleep has finished? What I am currently attempting to do is to make a goroutine that does time.Sleep() for the specified duration, and when that is finished it will broadcast a message to the channel. In my infinite loop, I listen for the message in the switch statement, and when it is there I