Posted on 25th April 2024
Timeouts are great for programs which connect toward the external resources or else that unless the necessary to bound execution time. Executing timeouts within Go is simple and elegant thanks to channels including select. Here is an example:
import "time"
c := make(chan error, 1)
go func() { c <- client.Call("Service.Method", args, &reply) } ()
select {
case err := <-c:
case <-time.After(timeoutNanoseconds):
}
STILL GOT QUERIES?