From 45670a7e5d18a4f992875c5d657fc0d0e3c0bf43 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sat, 30 Sep 2017 16:39:52 +0200 Subject: [PATCH] make vet happy: 'don't leak contexts' --- cmd/daemon.go | 1 + logger/logger.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/daemon.go b/cmd/daemon.go index 21f5e51..572f53a 100644 --- a/cmd/daemon.go +++ b/cmd/daemon.go @@ -103,6 +103,7 @@ outer: } signal.Stop(sigChan) + cancel() // make go vet happy log.Info("exiting") diff --git a/logger/logger.go b/logger/logger.go index e4a8f82..269b987 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -41,7 +41,7 @@ func (l *Logger) log(level Level, msg string) { entry := Entry{level, msg, time.Now(), l.fields} - ctx, _ := context.WithDeadline(context.Background(), time.Now().Add(l.outletTimeout)) + ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(l.outletTimeout)) ech := make(chan error) louts := l.outlets[level] @@ -64,6 +64,8 @@ func (l *Logger) log(level Level, msg string) { } } + cancel() // make go vet happy + } func (l *Logger) WithField(field string, val interface{}) *Logger {