16 lines
219 B
Go
16 lines
219 B
Go
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))
|
|
}
|