func ExampleGo() { var ( mgr = gls.NewContextManager() request_id_key = gls.GenSym() ) MyLog := func() { if request_id, ok := mgr.GetValue(request_id_key); ok { fmt.Println("My request id is:", request_id) } else { fmt.Println("No request id found") } } mgr.SetValues(gls.Values{request_id_key: "12345"}, func() { var wg sync.WaitGroup wg.Add(1) go func() { defer wg.Done() MyLog() }() wg.Wait() wg.Add(1) gls.Go(func() { defer wg.Done() MyLog() }) wg.Wait() }) // Output: No request id found // My request id is: 12345 }
func ExampleContextManager_SetValues() { var ( mgr = gls.NewContextManager() request_id_key = gls.GenSym() ) MyLog := func() { if request_id, ok := mgr.GetValue(request_id_key); ok { fmt.Println("My request id is:", request_id) } else { fmt.Println("No request id found") } } mgr.SetValues(gls.Values{request_id_key: "12345"}, func() { MyLog() }) MyLog() // Output: My request id is: 12345 // No request id found }