Posted on 26th March 2023
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?
Copyright © 2013 - 2023 MindMajix Technologies