From 81eedcd5bee3ed8907e5a3a231934f44c37239df Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 11 Feb 2020 10:35:55 -0800 Subject: [PATCH] ipnserver: ignore lint error for unused context. The linter is strictly correct, but the code is structured this way to avoid variable shadowing problems in the following for loop. The context doesn't leak. Staticcheck is correctly pointing out that this code is hard to follow. However, this chunk of code is in service of enforcing one frontend <> one backend, and we want to remove that limitation. So, we'll just ignore the lint warning until this entire piece of code goes away. Signed-off-by: David Anderson --- ipn/ipnserver/server.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ipn/ipnserver/server.go b/ipn/ipnserver/server.go index 8cbbf3ef4..d8ee50ee9 100644 --- a/ipn/ipnserver/server.go +++ b/ipn/ipnserver/server.go @@ -85,6 +85,10 @@ func Run(rctx context.Context, logf logger.Logf, logid string, opts Options, e w }() var oldS net.Conn + //lint:ignore SA4006 ctx is never used, but has to be defined so + // that it can be assigned to in the following for loop. It's a + // bit of necessary code convolution to work around Go's variable + // shadowing rules. ctx, cancel := context.WithCancel(rctx) stopAll := func() {