()
| 158 | } |
| 159 | |
| 160 | func ExampleSubscription_ErrorAs() { |
| 161 | // This example is specific to the gcppubsub implementation; it demonstrates |
| 162 | // access to the underlying Status type. |
| 163 | // The types exposed for As by gcppubsub are documented in |
| 164 | // https://godoc.org/gocloud.dev/pubsub/gcppubsub#hdr-As |
| 165 | |
| 166 | ctx := context.Background() |
| 167 | sub, err := pubsub.OpenSubscription(ctx, "gcppubsub://project/badtopic") |
| 168 | if err != nil { |
| 169 | log.Fatal(err) |
| 170 | } |
| 171 | defer sub.Shutdown(ctx) |
| 172 | |
| 173 | msg, err := sub.Receive(ctx) |
| 174 | if err != nil { |
| 175 | var s *status.Status |
| 176 | if sub.ErrorAs(err, &s) { |
| 177 | _ = s.Code() |
| 178 | } |
| 179 | log.Fatal(err) |
| 180 | } |
| 181 | msg.Ack() |
| 182 | } |
| 183 | |
| 184 | func ExampleTopic_As() { |
| 185 | // This example is specific to the gcppubsub implementation; it demonstrates |
nothing calls this directly
no test coverage detected