From bbc462717853fddb7631f4d46051f6038cfbf364 Mon Sep 17 00:00:00 2001 From: Alex Hong <9397363+hongalex@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:46:15 -0800 Subject: [PATCH 1/2] docs(pubsub): check for nil responses for receive examples --- pubsub/example_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pubsub/example_test.go b/pubsub/example_test.go index 514ae5871a8f..793b34d30c90 100644 --- a/pubsub/example_test.go +++ b/pubsub/example_test.go @@ -303,7 +303,7 @@ func ExampleSubscription_Receive() { // NOTE: May be called concurrently; synchronize access to shared memory. m.Ack() }) - if err != context.Canceled { + if err != nil && != context.Canceled { // TODO: Handle error. } } @@ -324,7 +324,7 @@ func ExampleSubscription_Receive_maxExtension() { // TODO: Handle message. m.Ack() }) - if err != context.Canceled { + if err != nil && != context.Canceled { // TODO: Handle error. } } @@ -345,7 +345,7 @@ func ExampleSubscription_Receive_maxOutstanding() { // TODO: Handle message. m.Ack() }) - if err != context.Canceled { + if err != nil && != context.Canceled { // TODO: Handle error. } } From 89bb7b86142873343e25047cbc57c5e325492e62 Mon Sep 17 00:00:00 2001 From: Alex Hong <9397363+hongalex@users.noreply.github.com> Date: Tue, 5 Mar 2024 17:43:08 -0800 Subject: [PATCH 2/2] make code compile actually --- pubsub/example_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pubsub/example_test.go b/pubsub/example_test.go index 793b34d30c90..07567521582a 100644 --- a/pubsub/example_test.go +++ b/pubsub/example_test.go @@ -303,7 +303,7 @@ func ExampleSubscription_Receive() { // NOTE: May be called concurrently; synchronize access to shared memory. m.Ack() }) - if err != nil && != context.Canceled { + if err != nil && err != context.Canceled { // TODO: Handle error. } } @@ -324,7 +324,7 @@ func ExampleSubscription_Receive_maxExtension() { // TODO: Handle message. m.Ack() }) - if err != nil && != context.Canceled { + if err != nil && err != context.Canceled { // TODO: Handle error. } } @@ -345,7 +345,7 @@ func ExampleSubscription_Receive_maxOutstanding() { // TODO: Handle message. m.Ack() }) - if err != nil && != context.Canceled { + if err != nil && err != context.Canceled { // TODO: Handle error. } }