...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package pubsub_test
16
17 import (
18 "context"
19 "fmt"
20
21 "cloud.google.com/go/pubsub"
22 "google.golang.org/api/iterator"
23 )
24
25 func ExampleClient_Topics() {
26 ctx := context.Background()
27 client, err := pubsub.NewClient(ctx, "project-id")
28 if err != nil {
29
30 }
31 it := client.Topics(ctx)
32 _ = it
33 }
34
35 func ExampleTopicIterator_Next() {
36 ctx := context.Background()
37 client, err := pubsub.NewClient(ctx, "project-id")
38 if err != nil {
39
40 }
41
42 it := client.Topics(ctx)
43 for {
44 t, err := it.Next()
45 if err == iterator.Done {
46 break
47 }
48 if err != nil {
49
50 }
51 fmt.Println(t)
52 }
53 }
54
View as plain text