Computer scienceProgramming languagesGolangPackages and modulesStandard libraryContext package

Context cancellation and timeouts

Block until canceled

Report a typo

Compose a function that prints a message after being blocked until the context it accepts as a parameter is canceled.

Reorder lines using drag or arrows. Adjust indentation with left buttons
                fmt.Println("the context is canceled")
              
                func waitForCancellation(ctx context.Context) error {
              
                }
              
                <-ctx.Done()
              

Create a free account to access the full topic