MCPcopy Index your code
hub / github.com/google/go-cloud / ExampleTopic_As

Function ExampleTopic_As

pubsub/example_test.go:184–201  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

182}
183
184func ExampleTopic_As() {
185 // This example is specific to the gcppubsub implementation; it demonstrates
186 // access to the underlying PublisherClient type.
187 // The types exposed for As by gcppubsub are documented in
188 // https://godoc.org/gocloud.dev/pubsub/gcppubsub#hdr-As
189
190 ctx := context.Background()
191 topic, err := pubsub.OpenTopic(ctx, "gcppubsub://project/topic")
192 if err != nil {
193 log.Fatal(err)
194 }
195 defer topic.Shutdown(ctx)
196
197 var pc *pbraw.PublisherClient
198 if topic.As(&pc) {
199 _ = pc
200 }
201}
202
203func ExampleTopic_ErrorAs() {
204 // This example is specific to the gcppubsub implementation; it demonstrates

Callers

nothing calls this directly

Calls 3

OpenTopicFunction · 0.92
ShutdownMethod · 0.65
AsMethod · 0.65

Tested by

no test coverage detected