func (b *Bundle) Add(f func(context.Context) error) {
	b.waitGroup.Add(1)

	// Run the function in the background.
	go func() {
		defer b.waitGroup.Done()

		err := f(b.context)
		if err == nil {
			return
		}

		// On first error, cancel the context and save the error.
		b.errorOnce.Do(func() {
			b.firstError = err
			b.cancel()
		})
	}()
}
func (b *Bundle) Add(f func(context.Context) error) {
	b.waitGroup.Add(1)

	// Run the function in the background.
	go func() {
		defer b.waitGroup.Done()

		err := f(b.context)
		if err == nil {
			return
		}

		// On first error, cancel the context and save the error.
		b.errorOnce.Do(func() {
			b.firstError = err
			b.cancel()
		})
	}()
}
func ( b * Bundle ) Add ( f func ( context . Context ) error ) { b . waitGroup . Add ( 1 ) // Run the function in the background. go func ( ) { defer b . waitGroup . Done ( ) err := f ( b . context ) if err == nil { return } // On first error, cancel the context and save the error. b . errorOnce . Do ( func ( ) { b . firstError = err b . cancel ( ) } ) } ( ) }
// Add a new operation to the bundle. The operation will be invoked with a
// context that will be cancelled if any other operation fails or has already
// failed.
Add a new operation to the bundle . The operation will be invoked with a context that will be cancelled if any other operation fails or has already failed .