Tutorial by Examples

A simple context tree (containing some common values that might be request scoped and included in a context) built from Go code like the following: // Pseudo-Go ctx := context.WithValue( context.WithDeadline( context.WithValue(context.Background(), sidKey, sid), time.Now().A...
Passing a context with a timeout (or with a cancel function) to a long running function can be used to cancel that functions work: ctx, _ := context.WithTimeout(context.Background(), 200*time.Millisecond) for { select { case <-ctx.Done(): return ctx.Err() default: ...

Page 1 of 1