Slide 18
Slide 18 text
Code after the fix
group, ctx := errgroup.WithContext(ctx)
// one sub request fails -> main request fails
group.Go(func() error {
var err error
profile, err = fetchProfile(ctx)
return err
})
// add a goroutine to the group
group.Go(func() error {
var err error
recommendations, err = fetchRecmdt(ctx)
return err
})
group.Go(func() error {
var err error
inventory, err = fetchInventory(ctx)
return err
})
if err := group.Wait(); err != nil {
return err
}
© 2025 Isovalent. All Rights Reserved.
// wait for the all goroutines
18