Исходники и презентации
This commit is contained in:
15
lessons/contexts/context_with_cancel_cause/main.go
Normal file
15
lessons/contexts/context_with_cancel_cause/main.go
Normal file
@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancelCause(context.Background())
|
||||
cancel(errors.New("error"))
|
||||
|
||||
fmt.Println(ctx.Err())
|
||||
fmt.Println(context.Cause(ctx))
|
||||
}
|
||||
Reference in New Issue
Block a user