Golang time.Time.After() and Before() functions examples

package time

Golang time.Time.After() and Before() functions usage examples

Golang time.Time.After() function usage example:

 case <-time.After(5 * time.Second):
 log.Fatal("presumed deadlock; no HTTP client activity seen in awhile")
 }

Golag time.Time.Before() function usage example:

 if d.Deadline.IsZero() || timeoutDeadline.Before(5 * time.Second) {
 return timeoutDeadline
 }

References :

http://golang.org/pkg/time/#Time.After

Advertisement