From 4f3685d11d61cde6c2aad24ee467056396cb061e Mon Sep 17 00:00:00 2001 From: Prabhjot Singh Sethi Date: Tue, 15 Apr 2025 16:53:51 +0000 Subject: [PATCH] Address golang lint errors Signed-off-by: Prabhjot Singh Sethi --- db/mongo.go | 5 ++++- db/mongo_test.go | 4 ++-- lock/owner.go | 4 +--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/db/mongo.go b/db/mongo.go index 39b28ca..aa34ab8 100644 --- a/db/mongo.go +++ b/db/mongo.go @@ -212,7 +212,10 @@ func (c *mongoCollection) Watch(ctx context.Context, filter interface{}, cb Watc // keeping the handles and stack clean // Note: this may not be required, if loop doesn't require it // but still it is safe to keep ensuring appropriate cleanup - defer stream.Close(context.Background()) + defer func() { + // ignore the error returned by stream close as of now + _ = stream.Close(context.Background()) + }() defer func() { if !errors.Is(ctx.Err(), context.Canceled) { // panic if the return from this function is not diff --git a/db/mongo_test.go b/db/mongo_test.go index a5ebc04..363c47a 100644 --- a/db/mongo_test.go +++ b/db/mongo_test.go @@ -217,9 +217,9 @@ func Test_CollectionWatch(t *testing.T) { mongoTestAddUpOps = 0 mongoTestDeleteOps = 0 myMongoTestDeleteOps = 0 - col.Watch(watchCtx, nil, myKeyWatcher) + _ = col.Watch(watchCtx, nil, myKeyWatcher) matchDeleteStage := mongo.Pipeline{bson.D{{Key: "$match", Value: bson.D{{Key: "operationType", Value: "delete"}}}}} - col.Watch(watchCtx, matchDeleteStage, myDeleteWatcher) + _ = col.Watch(watchCtx, matchDeleteStage, myDeleteWatcher) key := &MyKey{ Name: "test-key", diff --git a/lock/owner.go b/lock/owner.go index 785bbcf..b4f7f0a 100644 --- a/lock/owner.go +++ b/lock/owner.go @@ -153,7 +153,5 @@ func InitializeLockOwner(ctx context.Context, store db.Store, name string) error } // allocate owner entry context - ownerTable.allocateOwner(name) - - return nil + return ownerTable.allocateOwner(name) }