Post

GoLangGoLang

s
sri kanth

Posted on 21st February 2024|86 views

0
votes

Golang Select Timeout

golang select timeoutgolang select timeout

Answers
P
Lakshmi sowjanya

Posted on 21st February 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):

    }

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos