示例#1
0
func listTopics(client *pubsub.Client, argv []string) {
	checkArgs(argv, 1)
	topics, err := client.Topics(context.Background())
	if err != nil {
		log.Fatalf("Listing topics failed: %v", err)
	}
	for _, t := range topics {
		fmt.Println(t.Name())
	}
}
示例#2
0
func listTopics(client *pubsub.Client, argv []string) {
	ctx := context.Background()
	checkArgs(argv, 1)
	topics := client.Topics(ctx)
	for {
		switch topic, err := topics.Next(); err {
		case nil:
			fmt.Println(topic.Name())
		case pubsub.Done:
			return
		default:
			log.Fatalf("Listing topics failed: %v", err)
		}
	}
}