✏️ Context not Cotext

This commit is contained in:
Dan Jones 2024-12-03 15:20:06 -06:00
commit 1abe398c7a
3 changed files with 7 additions and 4 deletions

View file

@ -7,7 +7,11 @@ import (
"syscall"
)
func SelfCancelingCotext(ctx context.Context) (context.Context, context.CancelFunc) {
func SelfCancelingContextFromBackground() (context.Context, context.CancelFunc) {
return SelfCancelingContext(context.Background())
}
func SelfCancelingContext(ctx context.Context) (context.Context, context.CancelFunc) {
c, done := context.WithCancel(ctx)
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)