Fix grpc test vet warning (#3341)

This fixes the vet warning: the cancel function returned by
context.WithTimeout should be called, not discarded, to avoid a context
leak.

Signed-off-by: Ingo Gottwald <in.gottwald@gmail.com>
This commit is contained in:
Ingo Gottwald 2019-10-01 22:32:59 +02:00 committed by Miek Gieben
parent 575cea4496
commit fa6718d026

View file

@ -22,7 +22,8 @@ func TestGrpc(t *testing.T) {
}
defer g.Stop()
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
conn, err := grpc.DialContext(ctx, tcp, grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
t.Fatalf("Expected no error but got: %s", err)