Last active
February 20, 2023 20:06
-
-
Save marvinhosea/dadae464577fd31d13d3f7634eb1a4aa to your computer and use it in GitHub Desktop.
Cause
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"errors" | |
"log" | |
) | |
func main() { | |
ctx, cancelWithCause := context.WithCancelCause(context.Background()) | |
cancelWithCause(errors.New("error: cancellation cause")) | |
<-ctx.Done() | |
log.Println(ctx.Err()) | |
log.Println(context.Cause(ctx)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment