Run goroutine for t duration

I am new to Go. I am learning Go by doing a simple utility to test the performance of the URL by sending the requests concurrently.

I have implemented the concurrency using the waitgroup and go routines. However, I am not able to execute my program for t amount of duration.

NewTicker sends the request for every t seconds. But I would like to run go routine for t duration.

Any insights please? Thanks!

I think you want context.WithTimeout(t). Then use that context or contexts derived from it to expire requests.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.