Update Go dependencies and minimal Go version to 1.20 (#1650)

Signed-off-by: 6543 <6543@obermui.de>
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
Lauris BH
2023-03-21 01:48:15 +02:00
committed by GitHub
parent 60733c5cb9
commit 46452fbd84
29 changed files with 251 additions and 224 deletions

View File

@@ -16,6 +16,7 @@ package utils
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
@@ -24,7 +25,7 @@ import (
// Returns a copy of parent context that is canceled when
// an os interrupt signal is received.
func WithContextSigtermCallback(ctx context.Context, f func()) context.Context {
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithCancelCause(ctx)
go func() {
receivedSignal := make(chan os.Signal, 1)
signal.Notify(receivedSignal, syscall.SIGINT, syscall.SIGTERM)
@@ -33,7 +34,7 @@ func WithContextSigtermCallback(ctx context.Context, f func()) context.Context {
select {
case <-ctx.Done():
case <-receivedSignal:
cancel()
cancel(fmt.Errorf("received signal: %v", receivedSignal))
if f != nil {
f()
}