mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 02:34:02 +03:00
FILE / ScuroNeko/mtg
internal/utils/root_context_windows.go
Исходный файл и его история в репозитории.
24 lines
316 B
Go
24 lines
316 B
Go
// +build windows
|
|
|
|
package utils
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"os/signal"
|
|
)
|
|
|
|
func RootContext() context.Context {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
sigChan := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(sigChan, os.Interrupt)
|
|
go func() {
|
|
for range sigChan {
|
|
cancel()
|
|
}
|
|
}()
|
|
|
|
return ctx
|
|
}
|