OK, if I understand you correctly, the outer for loop is not needed and that
there should be two for loops.
the first for loop does step 1,2 and 3 and then "break" out of the loop 
when valid response is received
and then set the "interval".
The second for loop start a for _ := range ticker.C loop and also break out 
when there is a PATCH failure response.

Thanks for the advice 


 


On Saturday, March 20, 2021 at 12:48:15 PM UTC+2 Brian Candler wrote:

> One other minor point.  When you write
>
>         for _ = range ticker.C {
>             ...
>         }
>
> then you have a timer leak if you break or return from that loop but don't 
> call ticker.Stop().  If you only ever exit by "return" from the function, 
> then you can simply do:
>
>         ticker := time.NewTicker(time.Duration(Timer) * time.Second)
>         *defer ticker.Stop()*
>
> as per the example here <https://golang.org/pkg/time/#NewTicker>.  
> However since your code could never exit from that loop, it wasn't a 
> problem (and the outer "for { ... }" loop was unnecessary too)
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7f59c23e-6f07-4498-b56d-09435bff916an%40googlegroups.com.

Reply via email to